📑 目錄
- 1. aiva common config Function get settings
- 2. aiva common models Function non negative
- 3. aiva common mq Function init
- 4. aiva common schemas ai Function calculate base score
- 5. aiva common schemas ai Function validate plan id
- 6. aiva common schemas ai Function validate status
- 7. aiva common schemas ai Function validate training id
- 8. aiva common schemas base Function non negative
- 9. aiva common schemas enhanced Function to sarif result
- 10. aiva common schemas enhanced Function validate finding id
- 11. aiva common schemas enhanced Function validate task id
- 12. aiva common schemas findings Function validate finding id
- 13. aiva common schemas findings Function validate status
- 14. aiva common schemas findings Function validate task id
- 15. aiva common schemas system Function validate session id
- 16. aiva common schemas system Function validate status
- 17. aiva common schemas tasks Function validate priority
- 18. aiva common schemas tasks Function validate strategy
- 19. aiva common schemas tasks Function validate targets
- 20. aiva common schemas tasks Function validate task id
- 21. aiva common schemas telemetry Function record early stopping
- 22. aiva common schemas telemetry Function record error
- 23. aiva common schemas telemetry Function record oast callback
- 24. aiva common schemas telemetry Function to details
- 25. aiva common schemas telemetry Function update adaptive behavior
- 26. aiva common schemas telemetry Function validate event type
- 27. aiva common schemas telemetry Function validate status
- 28. aiva common utils dedup dedupe Function init
- 29. aiva common utils dedup dedupe Function prune
- 30. aiva common utils dedup dedupe Function clear
- 31. aiva common utils dedup dedupe Function close
- 32. aiva common utils dedup dedupe Function compute fingerprint
- 33. aiva common utils dedup dedupe Function count
- 34. aiva common utils dedup dedupe Function mark
- 35. aiva common utils dedup dedupe Function seen before
- 36. aiva common utils ids Function new id
- 37. aiva common utils logging Function get logger
- 38. aiva common utils network backoff Function init
- 39. aiva common utils network backoff Function resolve backoff
- 40. aiva common utils network backoff Function jitter backoff
- 41. aiva common utils network ratelimit Function init
- 42. aiva common utils network ratelimit Function apply rate
- 43. aiva common utils network ratelimit Function bucket for
- 44. aiva common utils network ratelimit Function bucket state
- 45. aiva common utils network ratelimit Function host rate
- 46. aiva common utils network ratelimit Function load state
- 47. aiva common utils network ratelimit Function maybe cleanup hosts
- 48. aiva common utils network ratelimit Function scale global
- 49. aiva common utils network ratelimit Function scale host
- 50. aiva common utils network ratelimit Function scale per host base
- 51. aiva common utils network ratelimit Function set global rate
- 52. aiva common utils network ratelimit Function set per host base
- 53. aiva common utils network ratelimit Function touch host
- 54. aiva common utils network ratelimit Function write state
- 55. aiva common utils network ratelimit Function cleanup expired hosts
- 56. aiva common utils network ratelimit Function load state
- 57. aiva common utils network ratelimit Function penalize
- 58. aiva common utils network ratelimit Function save state
- 59. aiva common utils network ratelimit Function should send
- 60. aiva common utils network ratelimit Function take
- 61. aiva common utils network ratelimit Function update from response
- 62. core aiva core ai commander Function init
- 63. core aiva core ai commander Function get status
- 64. core aiva core ai commander Function save state
- 65. core aiva core ai controller Function init
- 66. core aiva core ai controller Function analyze task complexity
- 67. core aiva core ai controller Function record unified decision
- 68. core aiva core ai controller Function get control statistics
- 69. core aiva core ai engine backup bio neuron core Function init
- 70. core aiva core ai engine backup bio neuron core Function create input vector
- 71. core aiva core ai engine backup bio neuron core Function softmax
- 72. core aiva core ai engine backup bio neuron core Function check confidence
- 73. core aiva core ai engine backup bio neuron core Function forward
- 74. core aiva core ai engine backup bio neuron core Function get knowledge stats
- 75. core aiva core ai engine backup bio neuron core Function invoke
- 76. core aiva core ai engine backup bio neuron core v2 Function init
- 77. core aiva core ai engine backup bio neuron core v2 Function check
- 78. core aiva core ai engine backup bio neuron core v2 Function forward
- 79. core aiva core ai engine backup bio neuron core v2 Function get history
- 80. core aiva core ai engine backup bio neuron core v2 Function get knowledge stats
- 81. core aiva core ai engine backup bio neuron core v2 Function invoke
- 82. core aiva core ai engine backup knowledge base Function init
- 83. core aiva core ai engine backup knowledge base Function add chunk
- 84. core aiva core ai engine backup knowledge base Function extract keywords
- 85. core aiva core ai engine backup knowledge base Function index file
- 86. core aiva core ai engine backup knowledge base Function get chunk count
- 87. core aiva core ai engine backup knowledge base Function get file content
- 88. core aiva core ai engine backup knowledge base Function index codebase
- 89. core aiva core ai engine backup knowledge base Function search
- 90. core aiva core ai engine backup tools Function init
- 91. core aiva core ai engine backup tools Function calculate complexity
- 92. core aiva core ai engine backup tools Function check docstrings
- 93. core aiva core ai engine backup tools Function check type hints
- 94. core aiva core ai engine backup tools Function execute
- 95. core aiva core ai engine bio neuron core Function init
- 96. core aiva core ai engine bio neuron core Function create input vector
- 97. core aiva core ai engine bio neuron core Function softmax
- 98. core aiva core ai engine bio neuron core Function check confidence
- 99. core aiva core ai engine bio neuron core Function forward
- 100. core aiva core ai engine bio neuron core Function get knowledge stats
- 101. core aiva core ai engine bio neuron core Function invoke
- 102. core aiva core ai engine bio neuron core Function train from experiences
- 103. core aiva core ai engine bio neuron core v2 Function init
- 104. core aiva core ai engine bio neuron core v2 Function check
- 105. core aiva core ai engine bio neuron core v2 Function forward
- 106. core aiva core ai engine bio neuron core v2 Function get history
- 107. core aiva core ai engine bio neuron core v2 Function get knowledge stats
- 108. core aiva core ai engine bio neuron core v2 Function invoke
- 109. core aiva core ai engine knowledge base Function init
- 110. core aiva core ai engine knowledge base Function add chunk
- 111. core aiva core ai engine knowledge base Function extract keywords
- 112. core aiva core ai engine knowledge base Function index file
- 113. core aiva core ai engine knowledge base Function get chunk count
- 114. core aiva core ai engine knowledge base Function get file content
- 115. core aiva core ai engine knowledge base Function index codebase
- 116. core aiva core ai engine knowledge base Function search
- 117. core aiva core ai engine tools Function init
- 118. core aiva core ai engine tools Function calculate complexity
- 119. core aiva core ai engine tools Function check docstrings
- 120. core aiva core ai engine tools Function check type hints
- 121. core aiva core ai engine tools Function execute
- 122. core aiva core ai engine training data loader Function init
- 123. core aiva core ai engine training data loader Function extract features
- 124. core aiva core ai engine training data loader Function prepare training data
- 125. core aiva core ai engine training data loader Function create validation split
- 126. core aiva core ai engine training data loader Function load dataset samples
- 127. core aiva core ai engine training data loader Function load training batch
- 128. core aiva core ai engine training model updater Function init
- 129. core aiva core ai engine training model updater Function save model
- 130. core aiva core ai engine training model updater Function load model
- 131. core aiva core ai engine training model updater Function schedule periodic update
- 132. core aiva core ai engine training model updater Function update from dataset
- 133. core aiva core ai engine training model updater Function update from recent experiences
- 134. core aiva core ai engine training trainer Function init
- 135. core aiva core ai engine training trainer Function backward batch
- 136. core aiva core ai engine training trainer Function forward batch
- 137. core aiva core ai engine training trainer Function train epoch
- 138. core aiva core ai engine training trainer Function validate
- 139. core aiva core ai engine training trainer Function get training summary
- 140. core aiva core ai engine training trainer Function train
- 141. core aiva core ai integration test Function init
- 142. core aiva core ai integration test Function generate recommendations
- 143. core aiva core ai integration test Function generate test report
- 144. core aiva core ai model train classifier Function create database
- 145. core aiva core ai model train classifier Function load data
- 146. core aiva core ai model train classifier Function train and save model
- 147. core aiva core ai ui schemas Function validate confidence
- 148. core aiva core ai ui schemas Function validate execution time
- 149. core aiva core ai ui schemas Function validate path
- 150. core aiva core ai ui schemas Function validate port
- 151. core aiva core ai ui schemas Function validate query
- 152. core aiva core ai ui schemas Function validate score
- 153. core aiva core ai ui schemas Function validate target
- 154. core aiva core ai ui schemas Function validate tool name
- 155. core aiva core ai ui schemas Function validate url
- 156. core aiva core analysis ast trace comparator Function init
- 157. core aiva core analysis ast trace comparator Function calculate completion
- 158. core aiva core analysis ast trace comparator Function calculate overall score
- 159. core aiva core analysis ast trace comparator Function calculate sequence match
- 160. core aiva core analysis ast trace comparator Function calculate timing
- 161. core aiva core analysis ast trace comparator Function count success failure
- 162. core aiva core analysis ast trace comparator Function extract actual steps
- 163. core aiva core analysis ast trace comparator Function extract expected steps
- 164. core aiva core analysis ast trace comparator Function find extra steps
- 165. core aiva core analysis ast trace comparator Function longest common subsequence
- 166. core aiva core analysis ast trace comparator Function compare
- 167. core aiva core analysis ast trace comparator Function generate feedback
- 168. core aiva core analysis ast trace comparator Function to dict
- 169. core aiva core analysis dynamic strategy adjustment Function init
- 170. core aiva core analysis dynamic strategy adjustment Function adjust based on success rate
- 171. core aiva core analysis dynamic strategy adjustment Function adjust for findings
- 172. core aiva core analysis dynamic strategy adjustment Function adjust for tech stack
- 173. core aiva core analysis dynamic strategy adjustment Function adjust for waf
- 174. core aiva core analysis dynamic strategy adjustment Function adjust
- 175. core aiva core analysis dynamic strategy adjustment Function learn from result
- 176. core aiva core analysis initial surface Function calculate risk score
- 177. core aiva core analysis initial surface Function detect idor candidates
- 178. core aiva core analysis initial surface Function detect sqli candidates
- 179. core aiva core analysis initial surface Function detect ssrf candidates
- 180. core aiva core analysis initial surface Function detect xss candidates
- 181. core aiva core analysis initial surface Function evaluate parameter
- 182. core aiva core analysis initial surface Function summarize asset
- 183. core aiva core analysis initial surface Function analyze
- 184. core aiva core analysis plan comparator Function init
- 185. core aiva core analysis plan comparator Function calculate quality bonus
- 186. core aiva core analysis plan comparator Function calculate reward score
- 187. core aiva core analysis plan comparator Function calculate sequence accuracy
- 188. core aiva core analysis plan comparator Function calculate step similarity
- 189. core aiva core analysis plan comparator Function check critical steps
- 190. core aiva core analysis plan comparator Function count extra actions
- 191. core aiva core analysis plan comparator Function evaluate goal achievement
- 192. core aiva core analysis plan comparator Function generate recommendations
- 193. core aiva core analysis plan comparator Function lcs length
- 194. core aiva core analysis plan comparator Function match steps
- 195. core aiva core analysis plan comparator Function compare
- 196. core aiva core analysis plan comparator Function generate comparison report
- 197. core aiva core analysis risk assessment engine Function init
- 198. core aiva core analysis risk assessment engine Function adjust by asset criticality
- 199. core aiva core analysis risk assessment engine Function adjust by exploitability
- 200. core aiva core analysis risk assessment engine Function calculate base score
- 201. core aiva core analysis risk assessment engine Function get risk level
- 202. core aiva core analysis strategy generator Function init
- 203. core aiva core analysis strategy generator Function calculate priority
- 204. core aiva core analysis strategy generator Function estimate duration
- 205. core aiva core analysis strategy generator Function generate idor tasks
- 206. core aiva core analysis strategy generator Function generate sqli tasks
- 207. core aiva core analysis strategy generator Function generate ssrf tasks
- 208. core aiva core analysis strategy generator Function generate xss tasks
- 209. core aiva core analysis strategy generator Function prioritize tasks
- 210. core aiva core analysis strategy generator Function generate
- 211. core aiva core app Function count tasks by type
- 212. core aiva core authz authz mapper Function init
- 213. core aiva core authz authz mapper Function analyze role overlap
- 214. core aiva core authz authz mapper Function assign role to user
- 215. core aiva core authz authz mapper Function check user permission
- 216. core aiva core authz authz mapper Function detect permission conflicts
- 217. core aiva core authz authz mapper Function get user all permissions
- 218. core aiva core authz authz mapper Function get user roles
- 219. core aiva core authz authz mapper Function main
- 220. core aiva core authz authz mapper Function recommend role consolidation
- 221. core aiva core authz authz mapper Function revoke role from user
- 222. core aiva core authz authz mapper Function set user attribute
- 223. core aiva core authz authz mapper Function simulate role removal
- 224. core aiva core authz matrix visualizer Function init
- 225. core aiva core authz matrix visualizer Function export to csv
- 226. core aiva core authz matrix visualizer Function generate coverage chart
- 227. core aiva core authz matrix visualizer Function generate heatmap
- 228. core aiva core authz matrix visualizer Function generate html report
- 229. core aiva core authz matrix visualizer Function generate role comparison chart
- 230. core aiva core authz matrix visualizer Function main
- 231. core aiva core authz permission matrix Function init
- 232. core aiva core authz permission matrix Function evaluate condition
- 233. core aiva core authz permission matrix Function add permission
- 234. core aiva core authz permission matrix Function add resource
- 235. core aiva core authz permission matrix Function add role
- 236. core aiva core authz permission matrix Function analyze coverage
- 237. core aiva core authz permission matrix Function check permission
- 238. core aiva core authz permission matrix Function export to dict
- 239. core aiva core authz permission matrix Function find over privileged roles
- 240. core aiva core authz permission matrix Function get resource permissions
- 241. core aiva core authz permission matrix Function get role permissions
- 242. core aiva core authz permission matrix Function grant permission
- 243. core aiva core authz permission matrix Function main
- 244. core aiva core authz permission matrix Function revoke permission
- 245. core aiva core authz permission matrix Function to dataframe
- 246. core aiva core authz permission matrix Function to numpy matrix
- 247. core aiva core bio neuron master Function init
- 248. core aiva core bio neuron master Function assess risk
- 249. core aiva core bio neuron master Function format status message
- 250. core aiva core bio neuron master Function get system status
- 251. core aiva core bio neuron master Function record interaction
- 252. core aiva core bio neuron master Function get conversation history
- 253. core aiva core bio neuron master Function register ui callback
- 254. core aiva core bio neuron master Function switch mode
- 255. core aiva core bizlogic finding helper Function create bizlogic finding
- 256. core aiva core business schemas Function validate task id
- 257. core aiva core execution execution status monitor Function init
- 258. core aiva core execution execution status monitor Function get recent alerts
- 259. core aiva core execution execution status monitor Function add alert
- 260. core aiva core execution execution status monitor Function check sla violations
- 261. core aiva core execution execution status monitor Function get system health
- 262. core aiva core execution execution status monitor Function record task completion
- 263. core aiva core execution execution status monitor Function record task start
- 264. core aiva core execution execution status monitor Function record worker heartbeat
- 265. core aiva core execution plan executor Function init
- 266. core aiva core execution plan executor Function calculate metrics
- 267. core aiva core execution plan executor Function calculate sequence accuracy
- 268. core aiva core execution plan executor Function generate recommendations
- 269. core aiva core execution plan executor Function prepare task payload
- 270. core aiva core execution task generator Function from strategy
- 271. core aiva core execution task queue manager Function init
- 272. core aiva core execution task queue manager Function enqueue task
- 273. core aiva core execution task queue manager Function get pending tasks
- 274. core aiva core execution task queue manager Function get queue status
- 275. core aiva core execution task queue manager Function mark task completed
- 276. core aiva core execution task queue manager Function mark task failed
- 277. core aiva core execution task queue manager Function mark task running
- 278. core aiva core execution task queue manager Function update task queue
- 279. core aiva core execution trace logger Function init
- 280. core aiva core execution trace logger Function update session state
- 281. core aiva core execution trace logger Function abort session
- 282. core aiva core execution trace logger Function complete session
- 283. core aiva core execution trace logger Function create session
- 284. core aiva core execution trace logger Function create trace record
- 285. core aiva core execution trace logger Function fail session
- 286. core aiva core execution trace logger Function get session
- 287. core aiva core execution trace logger Function update session status
- 288. core aiva core execution tracer execution monitor Function init
- 289. core aiva core execution tracer execution monitor Function complete task execution
- 290. core aiva core execution tracer execution monitor Function finalize monitoring
- 291. core aiva core execution tracer execution monitor Function get active tasks
- 292. core aiva core execution tracer execution monitor Function get trace summary
- 293. core aiva core execution tracer execution monitor Function record decision point
- 294. core aiva core execution tracer execution monitor Function record error
- 295. core aiva core execution tracer execution monitor Function record step
- 296. core aiva core execution tracer execution monitor Function record tool invocation
- 297. core aiva core execution tracer execution monitor Function start monitoring
- 298. core aiva core execution tracer execution monitor Function start task execution
- 299. core aiva core execution tracer task executor Function init
- 300. core aiva core execution tracer trace recorder Function init
- 301. core aiva core execution tracer trace recorder Function add entry
- 302. core aiva core execution tracer trace recorder Function finalize trace
- 303. core aiva core execution tracer trace recorder Function finalize
- 304. core aiva core execution tracer trace recorder Function get entries by task
- 305. core aiva core execution tracer trace recorder Function get entries by type
- 306. core aiva core execution tracer trace recorder Function get trace
- 307. core aiva core execution tracer trace recorder Function record error
- 308. core aiva core execution tracer trace recorder Function record http request
- 309. core aiva core execution tracer trace recorder Function record http response
- 310. core aiva core execution tracer trace recorder Function record log
- 311. core aiva core execution tracer trace recorder Function record task end
- 312. core aiva core execution tracer trace recorder Function record task start
- 313. core aiva core execution tracer trace recorder Function record
- 314. core aiva core execution tracer trace recorder Function start trace
- 315. core aiva core execution tracer trace recorder Function to dict
- 316. core aiva core execution tracer trace recorder Function to json
- 317. core aiva core learning experience manager Function init
- 318. core aiva core learning experience manager Function auto label
- 319. core aiva core learning experience manager Function calculate quality score
- 320. core aiva core learning experience manager Function extract context
- 321. core aiva core learning model trainer Function init
- 322. core aiva core learning model trainer Function build state vector
- 323. core aiva core learning model trainer Function calculate step reward
- 324. core aiva core learning model trainer Function encode action
- 325. core aiva core learning model trainer Function encode attack type
- 326. core aiva core learning model trainer Function extract features
- 327. core aiva core learning model trainer Function increment version
- 328. core aiva core learning model trainer Function prepare rl data
- 329. core aiva core learning model trainer Function prepare supervised data
- 330. core aiva core multilang coordinator Function init
- 331. core aiva core multilang coordinator Function analyze task requirements
- 332. core aiva core multilang coordinator Function distribute ai tasks
- 333. core aiva core multilang coordinator Function generate final recommendations
- 334. core aiva core multilang coordinator Function generate master synthesis
- 335. core aiva core multilang coordinator Function generate specific task
- 336. core aiva core multilang coordinator Function record coordination history
- 337. core aiva core multilang coordinator Function register language modules
- 338. core aiva core multilang coordinator Function select optimal ai modules
- 339. core aiva core multilang coordinator Function get coordination statistics
- 340. core aiva core nlg system Function init
- 341. core aiva core nlg system Function analyze context
- 342. core aiva core nlg system Function analyze sentiment
- 343. core aiva core nlg system Function detect intent
- 344. core aiva core nlg system Function determine response type
- 345. core aiva core nlg system Function extract entities
- 346. core aiva core nlg system Function extract filename
- 347. core aiva core nlg system Function extract technical details
- 348. core aiva core nlg system Function fill template
- 349. core aiva core nlg system Function generate result detail
- 350. core aiva core nlg system Function init context analyzers
- 351. core aiva core nlg system Function init response templates
- 352. core aiva core nlg system Function post process response
- 353. core aiva core nlg system Function select template
- 354. core aiva core nlg system Function generate response
- 355. core aiva core nlg system Function test nlg system
- 356. core aiva core optimized core Function init
- 357. core aiva core optimized core Function get cache key
- 358. core aiva core optimized core Function get memory usage mb
- 359. core aiva core optimized core Function make key
- 360. core aiva core optimized core Function update avg duration
- 361. core aiva core optimized core Function analyze current capabilities
- 362. core aiva core optimized core Function clear cache
- 363. core aiva core optimized core Function compare with gpt4
- 364. core aiva core optimized core Function decorator
- 365. core aiva core optimized core Function demonstrate self sufficiency
- 366. core aiva core optimized core Function final verdict
- 367. core aiva core optimized core Function get cache stats
- 368. core aiva core optimized core Function get memory stats
- 369. core aiva core optimized core Function get metrics summary
- 370. core aiva core optimized core Function get pool stats
- 371. core aiva core optimized core Function increment counter
- 372. core aiva core optimized core Function monitor performance
- 373. core aiva core optimized core Function prove aiva independence
- 374. core aiva core optimized core Function record duration
- 375. core aiva core optimized core Function register weak ref
- 376. core aiva core optimized core Function return component
- 377. core aiva core optimized core Function set gauge
- 378. core aiva core output to functions Function to function message
- 379. core aiva core output to functions Module
- 380. core aiva core planner ast parser Function init
- 381. core aiva core planner ast parser Function repr
- 382. core aiva core planner ast parser Function add edge
- 383. core aiva core planner ast parser Function add node
- 384. core aiva core planner ast parser Function create example sqli flow
- 385. core aiva core planner ast parser Function get next nodes
- 386. core aiva core planner ast parser Function get start node
- 387. core aiva core planner ast parser Function parse dict
- 388. core aiva core planner ast parser Function parse text
- 389. core aiva core planner ast parser Function validate
- 390. core aiva core planner orchestrator Function init
- 391. core aiva core planner orchestrator Function create execution plan
- 392. core aiva core planner orchestrator Function get decision for task
- 393. core aiva core planner orchestrator Function get next executable tasks
- 394. core aiva core planner orchestrator Function get plan summary
- 395. core aiva core planner orchestrator Function is plan complete
- 396. core aiva core planner orchestrator Function update task status
- 397. core aiva core planner task converter Function init
- 398. core aiva core planner task converter Function repr
- 399. core aiva core planner task converter Function create task from node
- 400. core aiva core planner task converter Function topological sort
- 401. core aiva core planner task converter Function add task
- 402. core aiva core planner task converter Function convert
- 403. core aiva core planner task converter Function get pending tasks
- 404. core aiva core planner task converter Function get runnable tasks
- 405. core aiva core planner task converter Function get task
- 406. core aiva core planner tool selector Function init
- 407. core aiva core planner tool selector Function repr
- 408. core aiva core planner tool selector Function determine endpoint and function
- 409. core aiva core planner tool selector Function determine routing key
- 410. core aiva core planner tool selector Function prepare parameters
- 411. core aiva core planner tool selector Function select service type
- 412. core aiva core planner tool selector Function select tool
- 413. core aiva core rag demo rag integration Function init
- 414. core aiva core rag demo rag integration Function build prompt with context
- 415. core aiva core rag knowledge base Function init
- 416. core aiva core rag knowledge base Function load knowledge base
- 417. core aiva core rag knowledge base Function add attack plan
- 418. core aiva core rag knowledge base Function add entry
- 419. core aiva core rag knowledge base Function add experience sample
- 420. core aiva core rag knowledge base Function from dict
- 421. core aiva core rag knowledge base Function get entry
- 422. core aiva core rag knowledge base Function get statistics
- 423. core aiva core rag knowledge base Function get top entries
- 424. core aiva core rag knowledge base Function save knowledge base
- 425. core aiva core rag knowledge base Function search
- 426. core aiva core rag knowledge base Function to dict
- 427. core aiva core rag knowledge base Function update usage stats
- 428. core aiva core rag rag engine Function init
- 429. core aiva core rag rag engine Function extract successful pattern
- 430. core aiva core rag rag engine Function analyze failure
- 431. core aiva core rag rag engine Function enhance attack plan
- 432. core aiva core rag rag engine Function get relevant payloads
- 433. core aiva core rag rag engine Function get statistics
- 434. core aiva core rag rag engine Function learn from experience
- 435. core aiva core rag rag engine Function save knowledge
- 436. core aiva core rag rag engine Function suggest next step
- 437. core aiva core rag vector store Function init
- 438. core aiva core rag vector store Function get embedding model
- 439. core aiva core rag vector store Function initialize backend
- 440. core aiva core rag vector store Function simple embedding
- 441. core aiva core rag vector store Function add batch
- 442. core aiva core rag vector store Function add document
- 443. core aiva core rag vector store Function delete document
- 444. core aiva core rag vector store Function get document
- 445. core aiva core rag vector store Function get statistics
- 446. core aiva core rag vector store Function load
- 447. core aiva core rag vector store Function save
- 448. core aiva core rag vector store Function search
- 449. core aiva core schemas Function all tasks
- 450. core aiva core schemas Function total candidates
- 451. core aiva core schemas Function total tasks
- 452. core aiva core schemas Function validate confidence
- 453. core aiva core schemas Function validate risk score
- 454. core aiva core state session state manager Function init
- 455. core aiva core state session state manager Function get session context
- 456. core aiva core state session state manager Function get session status
- 457. core aiva core state session state manager Function update context
- 458. core aiva core state session state manager Function update session status
- 459. core aiva core storage backends Function init
- 460. core aiva core storage config Function get storage config
- 461. core aiva core storage storage manager Function init
- 462. core aiva core storage storage manager Function create backend
- 463. core aiva core storage storage manager Function get dir size
- 464. core aiva core storage storage manager Function get path
- 465. core aiva core storage storage manager Function initialize
- 466. core aiva core training scenario manager Function init
- 467. core aiva core training scenario manager Function create juice shop sql login plan
- 468. core aiva core training scenario manager Function create juice shop xss dom plan
- 469. core aiva core training scenario manager Function create sql injection plan easy
- 470. core aiva core training scenario manager Function create sql injection plan medium
- 471. core aiva core training scenario manager Function create ssrf plan medium
- 472. core aiva core training scenario manager Function create xss plan easy
- 473. core aiva core training scenario manager Function estimate duration
- 474. core aiva core training training orchestrator Function init
- 475. core aiva core training training orchestrator Function save single session
- 476. core aiva core training training orchestrator Function get training statistics
- 477. core aiva core training training orchestrator Function save session
- 478. core aiva core ui panel auto server Function find free port
- 479. core aiva core ui panel auto server Function main
- 480. core aiva core ui panel auto server Function start auto server
- 481. core aiva core ui panel dashboard Function init
- 482. core aiva core ui panel dashboard Function get mode display
- 483. core aiva core ui panel dashboard Function init ai agent
- 484. core aiva core ui panel dashboard Function analyze code
- 485. core aiva core ui panel dashboard Function detect vulnerability
- 486. core aiva core ui panel dashboard Function get ai history
- 487. core aiva core ui panel dashboard Function get detections
- 488. core aiva core ui panel dashboard Function get stats
- 489. core aiva core ui panel dashboard Function get tasks
- 490. core aiva core ui panel dashboard Function read code
- 491. core aiva core ui panel improved ui Function build index html
- 492. core aiva core ui panel improved ui Function create app
- 493. core aiva core ui panel server Function find free port
- 494. core aiva core ui panel server Function start ui server
- 495. core models Function validate task id
- 496. function init Module
- 497. function common init Module
- 498. function common advanced detection config Function init
- 499. function common advanced detection config Function get compliance audit preset
- 500. function common advanced detection config Function get continuous monitoring preset
- 501. function common advanced detection config Function get penetration test preset
- 502. function common advanced detection config Function get red team preset
- 503. function common advanced detection config Function save config history
- 504. function common advanced detection config Function apply preset
- 505. function common advanced detection config Function from dict
- 506. function common advanced detection config Function get effective config
- 507. function common advanced detection config Function load from file
- 508. function common advanced detection config Function save to file
- 509. function common advanced detection config Function to dict
- 510. function common advanced detection config Function validate config
- 511. function common advanced detection config Module
- 512. function common detection config Function apply to config
- 513. function common detection config Module
- 514. function common unified smart detection manager Function init
- 515. function common unified smart detection manager Function avg response time
- 516. function common unified smart detection manager Function force stop
- 517. function common unified smart detection manager Function get performance summary
- 518. function common unified smart detection manager Function get timeout
- 519. function common unified smart detection manager Function on rate limit detected
- 520. function common unified smart detection manager Function on success
- 521. function common unified smart detection manager Function on test failure
- 522. function common unified smart detection manager Function on test success no vuln
- 523. function common unified smart detection manager Function on timeout
- 524. function common unified smart detection manager Function on vulnerability found
- 525. function common unified smart detection manager Function report vulnerability found
- 526. function common unified smart detection manager Function should continue testing
- 527. function common unified smart detection manager Function should continue
- 528. function common unified smart detection manager Function start detection
- 529. function common unified smart detection manager Function success rate
- 530. function common unified smart detection manager Function update progress
- 531. function common unified smart detection manager Function update
- 532. function common unified smart detection manager Module
- 533. function common worker statistics Function init
- 534. function common worker statistics Function add error
- 535. function common worker statistics Function add oast callback
- 536. function common worker statistics Function finalize
- 537. function common worker statistics Function get statistics
- 538. function common worker statistics Function get summary
- 539. function common worker statistics Function record early stopping
- 540. function common worker statistics Function record error
- 541. function common worker statistics Function record oast callback
- 542. function common worker statistics Function record oast probe
- 543. function common worker statistics Function record payload test
- 544. function common worker statistics Function record request
- 545. function common worker statistics Function record vulnerability
- 546. function common worker statistics Function set adaptive behavior
- 547. function common worker statistics Function set module specific
- 548. function common worker statistics Function to dict
- 549. function common worker statistics Function to summary
- 550. function common worker statistics Module
- 551. function function idor aiva func idor init Module
- 552. function function idor aiva func idor cross user tester Function init
- 553. function function idor aiva func idor cross user tester Module
- 554. function function idor aiva func idor enhanced worker Function init
- 555. function function idor aiva func idor enhanced worker Function convert to finding payloads
- 556. function function idor aiva func idor enhanced worker Function to details
- 557. function function idor aiva func idor enhanced worker Module
- 558. function function idor aiva func idor resource id extractor Function extract from url
- 559. function function idor aiva func idor resource id extractor Function generate test ids
- 560. function function idor aiva func idor resource id extractor Function replace id in url
- 561. function function idor aiva func idor resource id extractor Module
- 562. function function idor aiva func idor schemas Function analyze predictability
- 563. function function idor aiva func idor schemas Function get severity score
- 564. function function idor aiva func idor schemas Function get success rate
- 565. function function idor aiva func idor schemas Function is successful bypass
- 566. function function idor aiva func idor schemas Function record vector test
- 567. function function idor aiva func idor schemas Function to details
- 568. function function idor aiva func idor schemas Function validate method
- 569. function function idor aiva func idor schemas Function validate pattern
- 570. function function idor aiva func idor schemas Function validate resource type
- 571. function function idor aiva func idor schemas Function validate status code
- 572. function function idor aiva func idor schemas Module
- 573. function function idor aiva func idor smart idor detector Function init
- 574. function function idor aiva func idor smart idor detector Function build horizontal finding
- 575. function function idor aiva func idor smart idor detector Function build vertical finding
- 576. function function idor aiva func idor smart idor detector Function calculate total steps
- 577. function function idor aiva func idor smart idor detector Function add error
- 578. function function idor aiva func idor smart idor detector Function add finding
- 579. function function idor aiva func idor smart idor detector Function increment attempts
- 580. function function idor aiva func idor smart idor detector Module
- 581. function function idor aiva func idor vertical escalation tester Function init
- 582. function function idor aiva func idor vertical escalation tester Function infer required privilege
- 583. function function idor aiva func idor vertical escalation tester Module
- 584. function function idor aiva func idor worker Function init
- 585. function function idor aiva func idor worker Function build finding
- 586. function function idor aiva func idor worker Function build vertical finding
- 587. function function idor aiva func idor worker Function extract auth
- 588. function function idor aiva func idor worker Function get test user auth
- 589. function function idor aiva func idor worker Function infer required privilege
- 590. function function idor aiva func idor worker Function validated http url
- 591. function function idor aiva func idor worker Module
- 592. function function postex init Module
- 593. function function postex lateral movement Function init
- 594. function function postex lateral movement Function log action
- 595. function function postex lateral movement Function enumerate services
- 596. function function postex lateral movement Function get results
- 597. function function postex lateral movement Function main
- 598. function function postex lateral movement Function run full assessment
- 599. function function postex lateral movement Function simulate pass the hash
- 600. function function postex lateral movement Function test credential reuse
- 601. function function postex lateral movement Function test remote access
- 602. function function postex lateral movement Module
- 603. function function postex persistence checker Function init
- 604. function function postex persistence checker Function log action
- 605. function function postex persistence checker Function check cron jobs
- 606. function function postex persistence checker Function check registry persistence
- 607. function function postex persistence checker Function check scheduled tasks
- 608. function function postex persistence checker Function check services
- 609. function function postex persistence checker Function check startup items
- 610. function function postex persistence checker Function get results
- 611. function function postex persistence checker Function main
- 612. function function postex persistence checker Function run full assessment
- 613. function function postex persistence checker Module
- 614. function function postex privilege escalator Function init
- 615. function function postex privilege escalator Function check authorization
- 616. function function postex privilege escalator Function log action
- 617. function function postex privilege escalator Function check kernel exploits
- 618. function function postex privilege escalator Function check sudo misconfiguration
- 619. function function postex privilege escalator Function check suid binaries
- 620. function function postex privilege escalator Function check writable services
- 621. function function postex privilege escalator Function clear results
- 622. function function postex privilege escalator Function get results
- 623. function function postex privilege escalator Function main
- 624. function function postex privilege escalator Function run full assessment
- 625. function function postex privilege escalator Module
- 626. function function postex schemas Function calculate risk score
- 627. function function postex schemas Function get mitre techniques
- 628. function function postex schemas Function get stealth score
- 629. function function postex schemas Function get success rate
- 630. function function postex schemas Function record test result
- 631. function function postex schemas Function to details
- 632. function function postex schemas Function validate os type
- 633. function function postex schemas Function validate tactic
- 634. function function postex schemas Function validate technique id
- 635. function function postex schemas Function validate test type
- 636. function function postex schemas Module
- 637. function function sqli init Module
- 638. function function sqli aiva func sqli init Module
- 639. function function sqli aiva func sqli backend db fingerprinter Function init
- 640. function function sqli aiva func sqli backend db fingerprinter Function contains sql keywords
- 641. function function sqli aiva func sqli backend db fingerprinter Function extract error signatures
- 642. function function sqli aiva func sqli backend db fingerprinter Function extract version
- 643. function function sqli aiva func sqli backend db fingerprinter Function add custom pattern
- 644. function function sqli aiva func sqli backend db fingerprinter Function add custom version pattern
- 645. function function sqli aiva func sqli backend db fingerprinter Function analyze response characteristics
- 646. function function sqli aiva func sqli backend db fingerprinter Function fingerprint
- 647. function function sqli aiva func sqli backend db fingerprinter Function get supported databases
- 648. function function sqli aiva func sqli backend db fingerprinter Module
- 649. function function sqli aiva func sqli config Function create aggressive config
- 650. function function sqli aiva func sqli config Function create safe config
- 651. function function sqli aiva func sqli config Function get enabled engines
- 652. function function sqli aiva func sqli config Function is engine enabled
- 653. function function sqli aiva func sqli config Function to dict
- 654. function function sqli aiva func sqli config Function validate
- 655. function function sqli aiva func sqli config Module
- 656. function function sqli aiva func sqli detection models Function str
- 657. function function sqli aiva func sqli detection models Module
- 658. function function sqli aiva func sqli engines init Module
- 659. function function sqli aiva func sqli engines boolean detection engine Function init
- 660. function function sqli aiva func sqli engines boolean detection engine Function analyze boolean responses
- 661. function function sqli aiva func sqli engines boolean detection engine Function build detection result
- 662. function function sqli aiva func sqli engines boolean detection engine Module
- 663. function function sqli aiva func sqli engines error detection engine Function init
- 664. function function sqli aiva func sqli engines error detection engine Function analyze error response
- 665. function function sqli aiva func sqli engines error detection engine Function build detection result
- 666. function function sqli aiva func sqli engines error detection engine Module
- 667. function function sqli aiva func sqli engines oob detection engine Function init
- 668. function function sqli aiva func sqli engines oob detection engine Function build detection result
- 669. function function sqli aiva func sqli engines oob detection engine Function check oob response
- 670. function function sqli aiva func sqli engines oob detection engine Module
- 671. function function sqli aiva func sqli engines time detection engine Function init
- 672. function function sqli aiva func sqli engines time detection engine Function build detection result
- 673. function function sqli aiva func sqli engines time detection engine Module
- 674. function function sqli aiva func sqli engines union detection engine Function init
- 675. function function sqli aiva func sqli engines union detection engine Function build detection result
- 676. function function sqli aiva func sqli engines union detection engine Function check column count error
- 677. function function sqli aiva func sqli engines union detection engine Function check content change
- 678. function function sqli aiva func sqli engines union detection engine Function check union success
- 679. function function sqli aiva func sqli engines union detection engine Function get detection type
- 680. function function sqli aiva func sqli engines union detection engine Module
- 681. function function sqli aiva func sqli exceptions Function init
- 682. function function sqli aiva func sqli exceptions Function str
- 683. function function sqli aiva func sqli exceptions Module
- 684. function function sqli aiva func sqli payload wrapper encoder Function init
- 685. function function sqli aiva func sqli payload wrapper encoder Function inject query
- 686. function function sqli aiva func sqli payload wrapper encoder Function build request dump
- 687. function function sqli aiva func sqli payload wrapper encoder Function encode
- 688. function function sqli aiva func sqli payload wrapper encoder Module
- 689. function function sqli aiva func sqli result binder publisher Function init
- 690. function function sqli aiva func sqli result binder publisher Function worker id
- 691. function function sqli aiva func sqli result binder publisher Module
- 692. function function sqli aiva func sqli schemas Function str
- 693. function function sqli aiva func sqli schemas Function build request dump
- 694. function function sqli aiva func sqli schemas Function record detection
- 695. function function sqli aiva func sqli schemas Function record engine execution
- 696. function function sqli aiva func sqli schemas Function record error
- 697. function function sqli aiva func sqli schemas Function record payload sent
- 698. function function sqli aiva func sqli schemas Function to details
- 699. function function sqli aiva func sqli schemas Function validate detection method
- 700. function function sqli aiva func sqli schemas Function validate method
- 701. function function sqli aiva func sqli schemas Function validate timeout
- 702. function function sqli aiva func sqli schemas Module
- 703. function function sqli aiva func sqli smart detection manager Module
- 704. function function sqli aiva func sqli task queue Function init
- 705. function function sqli aiva func sqli task queue Module
- 706. function function sqli aiva func sqli telemetry Function add engine
- 707. function function sqli aiva func sqli telemetry Function add error
- 708. function function sqli aiva func sqli telemetry Function record detection
- 709. function function sqli aiva func sqli telemetry Function record engine execution
- 710. function function sqli aiva func sqli telemetry Function record error
- 711. function function sqli aiva func sqli telemetry Function record payload sent
- 712. function function sqli aiva func sqli telemetry Function to details
- 713. function function sqli aiva func sqli telemetry Module
- 714. function function sqli aiva func sqli worker Function init
- 715. function function sqli aiva func sqli worker Function create config from strategy
- 716. function function sqli aiva func sqli worker Function setup default engines
- 717. function function sqli aiva func sqli worker Function register engine
- 718. function function sqli aiva func sqli worker Function unregister engine
- 719. function function sqli aiva func sqli worker legacy Function init
- 720. function function sqli aiva func sqli worker legacy Function setup default engines
- 721. function function sqli aiva func sqli worker legacy Function register engine
- 722. function function sqli aiva func sqli worker legacy Function unregister engine
- 723. function function sqli aiva func sqli worker legacy Module
- 724. function function sqli aiva func sqli worker Module
- 725. function function ssrf init Module
- 726. function function ssrf aiva func ssrf init Module
- 727. function function ssrf aiva func ssrf enhanced worker Function init
- 728. function function ssrf aiva func ssrf enhanced worker Function convert to finding payloads
- 729. function function ssrf aiva func ssrf enhanced worker Function to details
- 730. function function ssrf aiva func ssrf enhanced worker Module
- 731. function function ssrf aiva func ssrf internal address detector Function assess risk level
- 732. function function ssrf aiva func ssrf internal address detector Function generate evidence
- 733. function function ssrf aiva func ssrf internal address detector Function identify service type
- 734. function function ssrf aiva func ssrf internal address detector Function is metadata response
- 735. function function ssrf aiva func ssrf internal address detector Function is protocol supported
- 736. function function ssrf aiva func ssrf internal address detector Function is service response
- 737. function function ssrf aiva func ssrf internal address detector Function is successful response
- 738. function function ssrf aiva func ssrf internal address detector Function test internal services
- 739. function function ssrf aiva func ssrf internal address detector Function test protocol support
- 740. function function ssrf aiva func ssrf internal address detector Function analyze
- 741. function function ssrf aiva func ssrf internal address detector Function is internal address
- 742. function function ssrf aiva func ssrf internal address detector Function summary
- 743. function function ssrf aiva func ssrf internal address detector Module
- 744. function function ssrf aiva func ssrf oast dispatcher Function init
- 745. function function ssrf aiva func ssrf oast dispatcher Function resolve token
- 746. function function ssrf aiva func ssrf oast dispatcher Module
- 747. function function ssrf aiva func ssrf param semantics analyzer Function build payloads
- 748. function function ssrf aiva func ssrf param semantics analyzer Function should enable oast
- 749. function function ssrf aiva func ssrf param semantics analyzer Function tokenize
- 750. function function ssrf aiva func ssrf param semantics analyzer Function analyze
- 751. function function ssrf aiva func ssrf param semantics analyzer Module
- 752. function function ssrf aiva func ssrf result publisher Function init
- 753. function function ssrf aiva func ssrf result publisher Function worker id
- 754. function function ssrf aiva func ssrf result publisher Module
- 755. function function ssrf aiva func ssrf schemas Function init
- 756. function function ssrf aiva func ssrf schemas Function record cloud metadata access
- 757. function function ssrf aiva func ssrf schemas Function record dns lookup
- 758. function function ssrf aiva func ssrf schemas Function record internal access
- 759. function function ssrf aiva func ssrf schemas Function record oast callback
- 760. function function ssrf aiva func ssrf schemas Function record protocol
- 761. function function ssrf aiva func ssrf schemas Function to details
- 762. function function ssrf aiva func ssrf schemas Function validate protocol
- 763. function function ssrf aiva func ssrf schemas Function validate vector type
- 764. function function ssrf aiva func ssrf schemas Function validate vectors
- 765. function function ssrf aiva func ssrf schemas Module
- 766. function function ssrf aiva func ssrf smart ssrf detector Function init
- 767. function function ssrf aiva func ssrf smart ssrf detector Function build internal finding
- 768. function function ssrf aiva func ssrf smart ssrf detector Function build oast finding
- 769. function function ssrf aiva func ssrf smart ssrf detector Function extract token
- 770. function function ssrf aiva func ssrf smart ssrf detector Function prioritize vectors
- 771. function function ssrf aiva func ssrf smart ssrf detector Function add error
- 772. function function ssrf aiva func ssrf smart ssrf detector Function add finding
- 773. function function ssrf aiva func ssrf smart ssrf detector Function add oast callbacks
- 774. function function ssrf aiva func ssrf smart ssrf detector Function increment attempts
- 775. function function ssrf aiva func ssrf smart ssrf detector Module
- 776. function function ssrf aiva func ssrf worker Function build internal finding
- 777. function function ssrf aiva func ssrf worker Function build oast finding
- 778. function function ssrf aiva func ssrf worker Function extract token
- 779. function function ssrf aiva func ssrf worker Function format request
- 780. function function ssrf aiva func ssrf worker Function format response
- 781. function function ssrf aiva func ssrf worker Function safe elapsed
- 782. function function ssrf aiva func ssrf worker Function severity from summary
- 783. function function ssrf aiva func ssrf worker Function to details
- 784. function function ssrf aiva func ssrf worker Module
- 785. function function xss init Module
- 786. function function xss aiva func xss init Module
- 787. function function xss aiva func xss blind xss listener validator Function init
- 788. function function xss aiva func xss blind xss listener validator Function resolve token
- 789. function function xss aiva func xss blind xss listener validator Module
- 790. function function xss aiva func xss dom xss detector Function analyze
- 791. function function xss aiva func xss dom xss detector Module
- 792. function function xss aiva func xss payload generator Function generate advanced payloads
- 793. function function xss aiva func xss payload generator Function generate all payloads
- 794. function function xss aiva func xss payload generator Function generate basic payloads
- 795. function function xss aiva func xss payload generator Function generate
- 796. function function xss aiva func xss payload generator Module
- 797. function function xss aiva func xss result publisher Function init
- 798. function function xss aiva func xss result publisher Function worker id
- 799. function function xss aiva func xss result publisher Module
- 800. function function xss aiva func xss schemas Function record blind callback
- 801. function function xss aiva func xss schemas Function record context
- 802. function function xss aiva func xss schemas Function record dom escalation
- 803. function function xss aiva func xss schemas Function record reflection
- 804. function function xss aiva func xss schemas Function record stored xss
- 805. function function xss aiva func xss schemas Function to detail
- 806. function function xss aiva func xss schemas Function to details
- 807. function function xss aiva func xss schemas Function validate method
- 808. function function xss aiva func xss schemas Function validate sink type
- 809. function function xss aiva func xss schemas Function validate source type
- 810. function function xss aiva func xss schemas Function validate status
- 811. function function xss aiva func xss schemas Module
- 812. function function xss aiva func xss stored detector Function init
- 813. function function xss aiva func xss stored detector Function fallback view url
- 814. function function xss aiva func xss stored detector Function inject query
- 815. function function xss aiva func xss stored detector Module
- 816. function function xss aiva func xss task queue Function init
- 817. function function xss aiva func xss task queue Function len
- 818. function function xss aiva func xss task queue Function discard invalid locked
- 819. function function xss aiva func xss task queue Module
- 820. function function xss aiva func xss traditional detector Function init
- 821. function function xss aiva func xss traditional detector Function build request parts
- 822. function function xss aiva func xss traditional detector Function inject mapping
- 823. function function xss aiva func xss traditional detector Function inject query
- 824. function function xss aiva func xss traditional detector Function payload in response
- 825. function function xss aiva func xss traditional detector Function errors
- 826. function function xss aiva func xss traditional detector Function to detail
- 827. function function xss aiva func xss traditional detector Module
- 828. function function xss aiva func xss worker Function build blind finding
- 829. function function xss aiva func xss worker Function build finding
- 830. function function xss aiva func xss worker Function build impact
- 831. function function xss aiva func xss worker Function build payloads
- 832. function function xss aiva func xss worker Function build recommendation
- 833. function function xss aiva func xss worker Function format request
- 834. function function xss aiva func xss worker Function format response
- 835. function function xss aiva func xss worker Function inject query
- 836. function function xss aiva func xss worker Function proof text
- 837. function function xss aiva func xss worker Function validated http url
- 838. function function xss aiva func xss worker Function to details
- 839. function function xss aiva func xss worker Module
- 840. function models Function validate function name
- 841. function models Function validate task id
- 842. function models Module
- 843. function test schemas Function validate priority
- 844. function test schemas Function validate task id
- 845. function test schemas Module
- 846. integration aiva integration analysis compliance policy checker Function init
- 847. integration aiva integration analysis compliance policy checker Function add custom policy
- 848. integration aiva integration analysis compliance policy checker Function check compliance
- 849. integration aiva integration analysis compliance policy checker Function get available policies
- 850. integration aiva integration analysis risk assessment engine enhanced Function init
- 851. integration aiva integration analysis risk assessment engine enhanced Function assess reputation risk
- 852. integration aiva integration analysis risk assessment engine enhanced Function calculate business impact factor
- 853. integration aiva integration analysis risk assessment engine enhanced Function calculate risk trend
- 854. integration aiva integration analysis risk assessment engine enhanced Function determine risk level enhanced
- 855. integration aiva integration analysis risk assessment engine enhanced Function estimate business impact
- 856. integration aiva integration analysis risk assessment engine enhanced Function generate enhanced recommendations
- 857. integration aiva integration analysis risk assessment engine enhanced Function assess risk
- 858. integration aiva integration analysis risk assessment engine enhanced Function compare risk trends
- 859. integration aiva integration analysis risk assessment engine Function init
- 860. integration aiva integration analysis risk assessment engine Function calculate business impact factor
- 861. integration aiva integration analysis risk assessment engine Function calculate risk trend
- 862. integration aiva integration analysis risk assessment engine Function determine risk level enhanced
- 863. integration aiva integration analysis risk assessment engine Function determine risk level
- 864. integration aiva integration analysis risk assessment engine Function estimate business impact
- 865. integration aiva integration analysis risk assessment engine Function generate enhanced recommendations
- 866. integration aiva integration analysis risk assessment engine Function generate impact summary
- 867. integration aiva integration analysis risk assessment engine Function generate recommendations
- 868. integration aiva integration analysis risk assessment engine Function get specific recommendation
- 869. integration aiva integration analysis risk assessment engine Function assess risk
- 870. integration aiva integration analysis risk assessment engine Function compare risk trends
- 871. integration aiva integration analysis vuln correlation analyzer Function init
- 872. integration aiva integration analysis vuln correlation analyzer Function analyze location clusters
- 873. integration aiva integration analysis vuln correlation analyzer Function are vulnerability types compatible
- 874. integration aiva integration analysis vuln correlation analyzer Function calculate flow impact
- 875. integration aiva integration analysis vuln correlation analyzer Function calculate risk amplification
- 876. integration aiva integration analysis vuln correlation analyzer Function check path correlation
- 877. integration aiva integration analysis vuln correlation analyzer Function count severities
- 878. integration aiva integration analysis vuln correlation analyzer Function describe attack chain
- 879. integration aiva integration analysis vuln correlation analyzer Function find correlation groups
- 880. integration aiva integration analysis vuln correlation analyzer Function generate correlation summary
- 881. integration aiva integration analysis vuln correlation analyzer Function generate root cause recommendation
- 882. integration aiva integration analysis vuln correlation analyzer Function identify attack chains
- 883. integration aiva integration analysis vuln correlation analyzer Function identify common components
- 884. integration aiva integration analysis vuln correlation analyzer Function analyze code level root cause
- 885. integration aiva integration analysis vuln correlation analyzer Function analyze correlations
- 886. integration aiva integration analysis vuln correlation analyzer Function analyze sast dast correlation
- 887. integration aiva integration attack path analyzer engine Function init
- 888. integration aiva integration attack path analyzer engine Function calculate risk score
- 889. integration aiva integration attack path analyzer engine Function create attack edges
- 890. integration aiva integration attack path analyzer engine Function generate path description
- 891. integration aiva integration attack path analyzer engine Function add asset
- 892. integration aiva integration attack path analyzer engine Function add finding
- 893. integration aiva integration attack path analyzer engine Function clear graph
- 894. integration aiva integration attack path analyzer engine Function close
- 895. integration aiva integration attack path analyzer engine Function find attack paths
- 896. integration aiva integration attack path analyzer engine Function find critical nodes
- 897. integration aiva integration attack path analyzer engine Function get vulnerability statistics
- 898. integration aiva integration attack path analyzer engine Function initialize graph
- 899. integration aiva integration attack path analyzer nlp recommender Function init
- 900. integration aiva integration attack path analyzer nlp recommender Function calculate priority score
- 901. integration aiva integration attack path analyzer nlp recommender Function determine risk level
- 902. integration aiva integration attack path analyzer nlp recommender Function estimate effort
- 903. integration aiva integration attack path analyzer nlp recommender Function estimate risk reduction
- 904. integration aiva integration attack path analyzer nlp recommender Function extract affected assets
- 905. integration aiva integration attack path analyzer nlp recommender Function generate business impact
- 906. integration aiva integration attack path analyzer nlp recommender Function generate executive summary
- 907. integration aiva integration attack path analyzer nlp recommender Function generate remediation steps
- 908. integration aiva integration attack path analyzer nlp recommender Function generate technical explanation
- 909. integration aiva integration attack path analyzer nlp recommender Function get current time
- 910. integration aiva integration attack path analyzer nlp recommender Function get node description
- 911. integration aiva integration attack path analyzer nlp recommender Function get node type name
- 912. integration aiva integration attack path analyzer nlp recommender Function identify quick wins
- 913. integration aiva integration attack path analyzer nlp recommender Function translate edge type
- 914. integration aiva integration attack path analyzer nlp recommender Function analyze and recommend
- 915. integration aiva integration attack path analyzer nlp recommender Function generate report
- 916. integration aiva integration attack path analyzer visualizer Function get node shape
- 917. integration aiva integration attack path analyzer visualizer Function to cytoscape json
- 918. integration aiva integration attack path analyzer visualizer Function to html
- 919. integration aiva integration attack path analyzer visualizer Function to mermaid
- 920. integration aiva integration config template config template manager Function init
- 921. integration aiva integration config template config template manager Function create custom template
- 922. integration aiva integration config template config template manager Function get template
- 923. integration aiva integration config template config template manager Function list templates
- 924. integration aiva integration examples enhanced attack path demo Function demo basic attack path analysis
- 925. integration aiva integration examples enhanced attack path demo Function demo critical nodes
- 926. integration aiva integration examples enhanced attack path demo Function demo generate full report
- 927. integration aiva integration examples enhanced attack path demo Function demo nlp recommendations
- 928. integration aiva integration examples enhanced attack path demo Function demo vulnerability statistics
- 929. integration aiva integration examples enhanced attack path demo Function main
- 930. integration aiva integration examples enhanced risk assessment demo Function example basic assessment
- 931. integration aiva integration examples enhanced risk assessment demo Function example comparison
- 932. integration aiva integration examples enhanced risk assessment demo Function example production critical asset
- 933. integration aiva integration examples enhanced risk assessment demo Function example trend analysis
- 934. integration aiva integration middlewares rate limiter Function init
- 935. integration aiva integration middlewares rate limiter Function get client ip
- 936. integration aiva integration observability metrics Function enter
- 937. integration aiva integration observability metrics Function exit
- 938. integration aiva integration observability metrics Function init
- 939. integration aiva integration observability metrics Function create timer
- 940. integration aiva integration observability metrics Function elapsed
- 941. integration aiva integration observability metrics Function get metrics
- 942. integration aiva integration observability metrics Function record finding processed
- 943. integration aiva integration observability metrics Function record http request
- 944. integration aiva integration observability metrics Function record report generated
- 945. integration aiva integration observability metrics Function record vulnerability found
- 946. integration aiva integration perf feedback improvement suggestion generator Function generate suggestions
- 947. integration aiva integration reception data reception layer Function init
- 948. integration aiva integration reception experience models Function repr
- 949. integration aiva integration reception experience repository Function init
- 950. integration aiva integration reception experience repository Function add samples to dataset
- 951. integration aiva integration reception experience repository Function create training dataset
- 952. integration aiva integration reception experience repository Function get dataset samples
- 953. integration aiva integration reception experience repository Function get experience
- 954. integration aiva integration reception experience repository Function get session
- 955. integration aiva integration reception experience repository Function get statistics
- 956. integration aiva integration reception experience repository Function get top experiences
- 957. integration aiva integration reception experience repository Function query experiences
- 958. integration aiva integration reception experience repository Function save experience
- 959. integration aiva integration reception experience repository Function save training history
- 960. integration aiva integration reception experience repository Function update training history
- 961. integration aiva integration reception lifecycle manager Function init
- 962. integration aiva integration reception lifecycle manager Function assess exploitability
- 963. integration aiva integration reception lifecycle manager Function calculate initial risk score
- 964. integration aiva integration reception lifecycle manager Function extract location key
- 965. integration aiva integration reception lifecycle manager Function extract location
- 966. integration aiva integration reception lifecycle manager Function extract vuln type
- 967. integration aiva integration reception lifecycle manager Function generate asset id
- 968. integration aiva integration reception lifecycle manager Function generate vulnerability id
- 969. integration aiva integration reception lifecycle manager Function infer asset id from finding
- 970. integration aiva integration reception lifecycle manager Function log status change
- 971. integration aiva integration reception lifecycle manager Function add vulnerability tag
- 972. integration aiva integration reception lifecycle manager Function assign vulnerability
- 973. integration aiva integration reception lifecycle manager Function calculate mttr
- 974. integration aiva integration reception lifecycle manager Function get asset vulnerabilities
- 975. integration aiva integration reception lifecycle manager Function get overdue vulnerabilities
- 976. integration aiva integration reception lifecycle manager Function process finding
- 977. integration aiva integration reception lifecycle manager Function register asset
- 978. integration aiva integration reception lifecycle manager Function update vulnerability status
- 979. integration aiva integration reception models enhanced Function repr
- 980. integration aiva integration reception models enhanced Function to dict
- 981. integration aiva integration reception sql result database Function init
- 982. integration aiva integration reception sql result database Function create tables
- 983. integration aiva integration reception sql result database Function get session
- 984. integration aiva integration reception sql result database Function to finding payload
- 985. integration aiva integration remediation code fixer Function init
- 986. integration aiva integration remediation code fixer Function build fix prompt
- 987. integration aiva integration remediation code fixer Function fix with llm
- 988. integration aiva integration remediation code fixer Function fix with mock
- 989. integration aiva integration remediation code fixer Function mock fix path traversal
- 990. integration aiva integration remediation code fixer Function mock fix sql injection
- 991. integration aiva integration remediation code fixer Function mock fix xss
- 992. integration aiva integration remediation code fixer Function parse llm response
- 993. integration aiva integration remediation code fixer Function fix multiple issues
- 994. integration aiva integration remediation code fixer Function fix vulnerability
- 995. integration aiva integration remediation code fixer Function get fix history
- 996. integration aiva integration remediation code fixer Function main
- 997. integration aiva integration remediation config recommender Function init
- 998. integration aiva integration remediation config recommender Function analyze application config
- 999. integration aiva integration remediation config recommender Function analyze database config
- 1000. integration aiva integration remediation config recommender Function analyze general config
- 1001. integration aiva integration remediation config recommender Function analyze web server config
- 1002. integration aiva integration remediation config recommender Function calculate risk level
- 1003. integration aiva integration remediation config recommender Function analyze security config
- 1004. integration aiva integration remediation config recommender Function export recommendations to yaml
- 1005. integration aiva integration remediation config recommender Function generate secure config
- 1006. integration aiva integration remediation config recommender Function get recommendations
- 1007. integration aiva integration remediation config recommender Function main
- 1008. integration aiva integration remediation patch generator Function init
- 1009. integration aiva integration remediation patch generator Function generate git diff
- 1010. integration aiva integration remediation patch generator Function generate simple patch
- 1011. integration aiva integration remediation patch generator Function suggest html escape
- 1012. integration aiva integration remediation patch generator Function suggest parameterized query
- 1013. integration aiva integration remediation patch generator Function apply patch
- 1014. integration aiva integration remediation patch generator Function export patches
- 1015. integration aiva integration remediation patch generator Function generate patch for vulnerability
- 1016. integration aiva integration remediation patch generator Function generate sql injection patch
- 1017. integration aiva integration remediation patch generator Function generate xss patch
- 1018. integration aiva integration remediation patch generator Function get patches
- 1019. integration aiva integration remediation patch generator Function main
- 1020. integration aiva integration remediation report generator Function init
- 1021. integration aiva integration remediation report generator Function calculate fix statistics
- 1022. integration aiva integration remediation report generator Function calculate vuln statistics
- 1023. integration aiva integration remediation report generator Function generate html report
- 1024. integration aiva integration remediation report generator Function generate inline html
- 1025. integration aiva integration remediation report generator Function generate markdown report
- 1026. integration aiva integration remediation report generator Function generate pdf report
- 1027. integration aiva integration remediation report generator Function generate remediation html
- 1028. integration aiva integration remediation report generator Function generate remediation markdown
- 1029. integration aiva integration remediation report generator Function generate reportlab pdf
- 1030. integration aiva integration remediation report generator Function generate remediation report
- 1031. integration aiva integration remediation report generator Function generate vulnerability report
- 1032. integration aiva integration remediation report generator Function get reports
- 1033. integration aiva integration remediation report generator Function main
- 1034. integration aiva integration reporting formatter exporter Function init
- 1035. integration aiva integration reporting formatter exporter Function dict to xml
- 1036. integration aiva integration reporting formatter exporter Function export csv
- 1037. integration aiva integration reporting formatter exporter Function export html
- 1038. integration aiva integration reporting formatter exporter Function export json
- 1039. integration aiva integration reporting formatter exporter Function export xml
- 1040. integration aiva integration reporting formatter exporter Function export to format
- 1041. integration aiva integration reporting formatter exporter Function get supported formats
- 1042. integration aiva integration reporting report content generator Function init
- 1043. integration aiva integration reporting report content generator Function extract risk factors
- 1044. integration aiva integration reporting report content generator Function format compliance result
- 1045. integration aiva integration reporting report content generator Function format correlation analysis
- 1046. integration aiva integration reporting report content generator Function generate appendices
- 1047. integration aiva integration reporting report content generator Function generate executive summary
- 1048. integration aiva integration reporting report content generator Function generate findings summary
- 1049. integration aiva integration reporting report content generator Function generate metadata
- 1050. integration aiva integration reporting report content generator Function generate recommendations
- 1051. integration aiva integration reporting report content generator Function generate risk overview
- 1052. integration aiva integration reporting report content generator Function generate technical details
- 1053. integration aiva integration reporting report content generator Function get highest severity
- 1054. integration aiva integration reporting report content generator Function get severity definitions
- 1055. integration aiva integration reporting report content generator Function get vuln classifications
- 1056. integration aiva integration reporting report content generator Function generate report content
- 1057. integration aiva integration reporting report template selector Function init
- 1058. integration aiva integration reporting report template selector Function get available templates
- 1059. integration aiva integration reporting report template selector Function select template
- 1060. integration aiva integration security auth Function init
- 1061. integration aiva integration settings Function load
- 1062. integration aiva integration settings Function use sql storage
- 1063. integration aiva integration settings Function validate
- 1064. integration aiva integration threat intel threat intel intel aggregator Function init
- 1065. integration aiva integration threat intel threat intel intel aggregator Function calculate abuseipdb threat level
- 1066. integration aiva integration threat intel threat intel intel aggregator Function calculate vt threat level
- 1067. integration aiva integration threat intel threat intel intel aggregator Function generate cache key
- 1068. integration aiva integration threat intel threat intel intel aggregator Function get available sources
- 1069. integration aiva integration threat intel threat intel intel aggregator Function get from cache
- 1070. integration aiva integration threat intel threat intel intel aggregator Function set to cache
- 1071. integration aiva integration threat intel threat intel intel aggregator Function clear cache
- 1072. integration aiva integration threat intel threat intel ioc enricher Function del
- 1073. integration aiva integration threat intel threat intel ioc enricher Function init
- 1074. integration aiva integration threat intel threat intel ioc enricher Function analyze tld
- 1075. integration aiva integration threat intel threat intel ioc enricher Function detect hash type
- 1076. integration aiva integration threat intel threat intel ioc enricher Function query geoip
- 1077. integration aiva integration threat intel threat intel ioc enricher Function rdns lookup
- 1078. integration aiva integration threat intel threat intel ioc enricher Function resolve
- 1079. integration aiva integration threat intel threat intel ioc enricher Function whois query
- 1080. integration aiva integration threat intel threat intel ioc enricher Function whois
- 1081. integration aiva integration threat intel threat intel mitre mapper Function init
- 1082. integration aiva integration threat intel threat intel mitre mapper Function extract tactics
- 1083. integration aiva integration threat intel threat intel mitre mapper Function load attack data
- 1084. integration aiva integration threat intel threat intel mitre mapper Function generate attack path
- 1085. integration aiva integration threat intel threat intel mitre mapper Function get mitigations for technique
- 1086. integration aiva integration threat intel threat intel mitre mapper Function get tactics
- 1087. integration aiva integration threat intel threat intel mitre mapper Function get technique by id
- 1088. integration aiva integration threat intel threat intel mitre mapper Function main
- 1089. integration aiva integration threat intel threat intel mitre mapper Function map vulnerability to techniques
- 1090. integration aiva integration threat intel threat intel mitre mapper Function search techniques by keyword
- 1091. integration alembic env Function do run migrations
- 1092. integration alembic env Function get database url
- 1093. integration alembic env Function run migrations offline
- 1094. integration alembic env Function run migrations online
- 1095. integration alembic versions 001 initial schema Function downgrade
- 1096. integration alembic versions 001 initial schema Function upgrade
- 1097. message broker Function init
- 1098. result collector Function init
- 1099. result collector Function set pending result
- 1100. result collector Function register handler
- 1101. result collector Function unregister handler
- 1102. task dispatcher Function init
- 1103. task dispatcher Function build message
- 1104. task dispatcher Function build task payload
- 1105. task dispatcher Function get topic for tool
- 1106. task dispatcher Function register callback
- 1107. task dispatcher Function unregister callback
- 1108. aiva func sqli init Module
- 1109. aiva func sqli backend db fingerprinter Function init
- 1110. aiva func sqli backend db fingerprinter Function contains sql keywords
- 1111. aiva func sqli backend db fingerprinter Function extract error signatures
- 1112. aiva func sqli backend db fingerprinter Function extract version
- 1113. aiva func sqli backend db fingerprinter Function add custom pattern
- 1114. aiva func sqli backend db fingerprinter Function add custom version pattern
- 1115. aiva func sqli backend db fingerprinter Function analyze response characteristics
- 1116. aiva func sqli backend db fingerprinter Function fingerprint
- 1117. aiva func sqli backend db fingerprinter Function get supported databases
- 1118. aiva func sqli backend db fingerprinter Module
- 1119. aiva func sqli config Function create aggressive config
- 1120. aiva func sqli config Function create safe config
- 1121. aiva func sqli config Function get enabled engines
- 1122. aiva func sqli config Function is engine enabled
- 1123. aiva func sqli config Function to dict
- 1124. aiva func sqli config Function validate
- 1125. aiva func sqli config Module
- 1126. aiva func sqli detection models Function str
- 1127. aiva func sqli detection models Module
- 1128. aiva func sqli engines init Module
- 1129. aiva func sqli engines boolean detection engine Function init
- 1130. aiva func sqli engines boolean detection engine Function analyze boolean responses
- 1131. aiva func sqli engines boolean detection engine Function build detection result
- 1132. aiva func sqli engines boolean detection engine Module
- 1133. aiva func sqli engines error detection engine Function init
- 1134. aiva func sqli engines error detection engine Function analyze error response
- 1135. aiva func sqli engines error detection engine Function build detection result
- 1136. aiva func sqli engines error detection engine Module
- 1137. aiva func sqli engines oob detection engine Function init
- 1138. aiva func sqli engines oob detection engine Function build detection result
- 1139. aiva func sqli engines oob detection engine Function check oob response
- 1140. aiva func sqli engines oob detection engine Module
- 1141. aiva func sqli engines time detection engine Function init
- 1142. aiva func sqli engines time detection engine Function build detection result
- 1143. aiva func sqli engines time detection engine Module
- 1144. aiva func sqli engines union detection engine Function init
- 1145. aiva func sqli engines union detection engine Function build detection result
- 1146. aiva func sqli engines union detection engine Function check column count error
- 1147. aiva func sqli engines union detection engine Function check content change
- 1148. aiva func sqli engines union detection engine Function check union success
- 1149. aiva func sqli engines union detection engine Function get detection type
- 1150. aiva func sqli engines union detection engine Module
- 1151. aiva func sqli exceptions Function init
- 1152. aiva func sqli exceptions Function str
- 1153. aiva func sqli exceptions Module
- 1154. aiva func sqli payload wrapper encoder Function init
- 1155. aiva func sqli payload wrapper encoder Function inject query
- 1156. aiva func sqli payload wrapper encoder Function build request dump
- 1157. aiva func sqli payload wrapper encoder Function encode
- 1158. aiva func sqli payload wrapper encoder Module
- 1159. aiva func sqli result binder publisher Function init
- 1160. aiva func sqli result binder publisher Function worker id
- 1161. aiva func sqli result binder publisher Module
- 1162. aiva func sqli schemas Function str
- 1163. aiva func sqli schemas Function build request dump
- 1164. aiva func sqli schemas Function record detection
- 1165. aiva func sqli schemas Function record engine execution
- 1166. aiva func sqli schemas Function record error
- 1167. aiva func sqli schemas Function record payload sent
- 1168. aiva func sqli schemas Function to details
- 1169. aiva func sqli schemas Function validate detection method
- 1170. aiva func sqli schemas Function validate method
- 1171. aiva func sqli schemas Function validate timeout
- 1172. aiva func sqli schemas Module
- 1173. aiva func sqli smart detection manager Module
- 1174. aiva func sqli task queue Function init
- 1175. aiva func sqli task queue Module
- 1176. aiva func sqli telemetry Function add engine
- 1177. aiva func sqli telemetry Function add error
- 1178. aiva func sqli telemetry Function record detection
- 1179. aiva func sqli telemetry Function record engine execution
- 1180. aiva func sqli telemetry Function record error
- 1181. aiva func sqli telemetry Function record payload sent
- 1182. aiva func sqli telemetry Function to details
- 1183. aiva func sqli telemetry Module
- 1184. aiva func sqli worker Function init
- 1185. aiva func sqli worker Function create config from strategy
- 1186. aiva func sqli worker Function setup default engines
- 1187. aiva func sqli worker Function register engine
- 1188. aiva func sqli worker Function unregister engine
- 1189. aiva func sqli worker legacy Function init
- 1190. aiva func sqli worker legacy Function setup default engines
- 1191. aiva func sqli worker legacy Function register engine
- 1192. aiva func sqli worker legacy Function unregister engine
- 1193. aiva func sqli worker legacy Module
- 1194. aiva func sqli worker Module
- 1195. authentication manager Function init
- 1196. config control center Function init
- 1197. config control center Function dataclass to dict
- 1198. config control center Function get aggressive preset
- 1199. config control center Function get balanced preset
- 1200. config control center Function get conservative preset
- 1201. config control center Function get deep preset
- 1202. config control center Function get fast preset
- 1203. config control center Function get stealth preset
- 1204. config control center Function save snapshot
- 1205. config control center Function validate config
- 1206. config control center Function apply preset
- 1207. config control center Function export config
- 1208. config control center Function get config summary
- 1209. config control center Function get config
- 1210. config control center Function get crawling config
- 1211. config control center Function get dynamic config
- 1212. config control center Function get fingerprint config
- 1213. config control center Function get performance config
- 1214. config control center Function get reporting config
- 1215. config control center Function get security config
- 1216. config control center Function reset to defaults
- 1217. config control center Function restore previous config
- 1218. config control center Function update crawling config
- 1219. config control center Function update dynamic config
- 1220. config control center Function update performance config
- 1221. config control center Function update security config
- 1222. core crawling engine http client hi Function init
- 1223. core crawling engine static content parser Function extract
- 1224. core crawling engine url queue manager Function init
- 1225. core crawling engine url queue manager Function len
- 1226. core crawling engine url queue manager Function repr
- 1227. core crawling engine url queue manager Function normalize url
- 1228. core crawling engine url queue manager Function add batch
- 1229. core crawling engine url queue manager Function add
- 1230. core crawling engine url queue manager Function clear
- 1231. core crawling engine url queue manager Function get statistics
- 1232. core crawling engine url queue manager Function has next
- 1233. core crawling engine url queue manager Function is processed
- 1234. core crawling engine url queue manager Function is seen
- 1235. core crawling engine url queue manager Function next
- 1236. dynamic engine ajax api handler Function init
- 1237. dynamic engine ajax api handler Function create api asset
- 1238. dynamic engine ajax api handler Function is valid endpoint
- 1239. dynamic engine ajax api handler Function normalize url
- 1240. dynamic engine ajax api handler Function get discovered endpoints
- 1241. dynamic engine ajax api handler Function get statistics
- 1242. dynamic engine dynamic content extractor Function init
- 1243. dynamic engine dynamic content extractor Function clear
- 1244. dynamic engine dynamic content extractor Function convert to assets
- 1245. dynamic engine dynamic content extractor Function get contents by type
- 1246. dynamic engine dynamic content extractor Function get extracted contents
- 1247. dynamic engine dynamic content extractor Function get network requests
- 1248. dynamic engine dynamic content extractor Function get stats
- 1249. dynamic engine headless browser pool Function init
- 1250. dynamic engine headless browser pool Function get browser info
- 1251. dynamic engine headless browser pool Function get stats
- 1252. dynamic engine headless browser pool Function list browsers
- 1253. dynamic engine headless browser pool Function list pages
- 1254. dynamic engine js interaction simulator Function init
- 1255. dynamic engine js interaction simulator Function get events by type
- 1256. dynamic engine js interaction simulator Function add click
- 1257. dynamic engine js interaction simulator Function add event
- 1258. dynamic engine js interaction simulator Function add hover
- 1259. dynamic engine js interaction simulator Function add input
- 1260. dynamic engine js interaction simulator Function add scroll
- 1261. dynamic engine js interaction simulator Function add submit
- 1262. dynamic engine js interaction simulator Function clear queue
- 1263. dynamic engine js interaction simulator Function get results
- 1264. dynamic engine js interaction simulator Function get stats
- 1265. dynamic engine js interaction simulator Function get success rate
- 1266. fingerprint manager Function init
- 1267. fingerprint manager Function get final fingerprints
- 1268. fingerprint manager Function merge
- 1269. fingerprint manager Function reset
- 1270. header configuration Function init
- 1271. header configuration Function get random user agent
- 1272. header configuration Function add header
- 1273. header configuration Function clear custom headers
- 1274. header configuration Function clone
- 1275. header configuration Function create api config
- 1276. header configuration Function create minimal config
- 1277. header configuration Function create stealth config
- 1278. header configuration Function enable user agent rotation
- 1279. header configuration Function from dict
- 1280. header configuration Function get custom headers
- 1281. header configuration Function get default headers
- 1282. header configuration Function get default user agents
- 1283. header configuration Function get headers for api
- 1284. header configuration Function get headers summary
- 1285. header configuration Function get headers
- 1286. header configuration Function get user agent
- 1287. header configuration Function merge headers
- 1288. header configuration Function remove header
- 1289. header configuration Function set authorization
- 1290. header configuration Function set cookie
- 1291. header configuration Function set referer
- 1292. header configuration Function set user agent
- 1293. header configuration Function to dict
- 1294. info gatherer javascript source analyzer Function init
- 1295. info gatherer javascript source analyzer Function analyze dataflow
- 1296. info gatherer javascript source analyzer Function build security patterns
- 1297. info gatherer javascript source analyzer Function build sink patterns
- 1298. info gatherer javascript source analyzer Function build source patterns
- 1299. info gatherer javascript source analyzer Function count by type
- 1300. info gatherer javascript source analyzer Function detect patterns
- 1301. info gatherer javascript source analyzer Function detect sinks
- 1302. info gatherer javascript source analyzer Function extract context
- 1303. info gatherer javascript source analyzer Function analyze
- 1304. info gatherer javascript source analyzer Function format report
- 1305. info gatherer javascript source analyzer Function get high risk issues
- 1306. info gatherer javascript source analyzer Function get stats
- 1307. info gatherer passive fingerprinter Function from headers
- 1308. info gatherer sensitive info detector Function init
- 1309. info gatherer sensitive info detector Function post init
- 1310. info gatherer sensitive info detector Function build patterns
- 1311. info gatherer sensitive info detector Function count by location
- 1312. info gatherer sensitive info detector Function count by type
- 1313. info gatherer sensitive info detector Function detect html comments
- 1314. info gatherer sensitive info detector Function detect in text
- 1315. info gatherer sensitive info detector Function detect meta tags
- 1316. info gatherer sensitive info detector Function detect script blocks
- 1317. info gatherer sensitive info detector Function filter by severity
- 1318. info gatherer sensitive info detector Function get default description
- 1319. info gatherer sensitive info detector Function get default recommendation
- 1320. info gatherer sensitive info detector Function detect in headers
- 1321. info gatherer sensitive info detector Function detect in html
- 1322. info gatherer sensitive info detector Function detect in javascript
- 1323. info gatherer sensitive info detector Function detect in response
- 1324. info gatherer sensitive info detector Function format report
- 1325. info gatherer sensitive info detector Function get critical issues
- 1326. info gatherer sensitive info detector Function get high risk issues
- 1327. info gatherer sensitive info detector Function get stats
- 1328. javascript analyzer Function init
- 1329. javascript analyzer Function calculate security score
- 1330. javascript analyzer Function detect dangerous functions
- 1331. javascript analyzer Function detect data leaks
- 1332. javascript analyzer Function extract external resources
- 1333. javascript analyzer Function clear results
- 1334. javascript analyzer Function get all results
- 1335. javascript analyzer Function get statistics
- 1336. schemas Function init
- 1337. schemas Function get default description
- 1338. schemas Function get default recommendation
- 1339. schemas Function limit list size
- 1340. schemas Function limit urls
- 1341. schemas Function validate method
- 1342. schemas Function validate request type
- 1343. scope manager Function init
- 1344. scope manager Function compile exclusion patterns
- 1345. scope manager Function compile pattern
- 1346. scope manager Function is host allowed
- 1347. scope manager Function is valid hostname
- 1348. scope manager Function matches exclusion
- 1349. scope manager Function add allowed host
- 1350. scope manager Function add exclusion
- 1351. scope manager Function clone
- 1352. scope manager Function filter urls
- 1353. scope manager Function get allowed hosts
- 1354. scope manager Function get exclusions
- 1355. scope manager Function get scope summary
- 1356. scope manager Function get stats
- 1357. scope manager Function is host allowed
- 1358. scope manager Function is in scope
- 1359. scope manager Function is subdomain included
- 1360. scope manager Function merge with
- 1361. scope manager Function remove allowed host
- 1362. scope manager Function remove exclusion
- 1363. scope manager Function reset stats
- 1364. scope manager Function set include subdomains
- 1365. scope manager Function validate scope
- 1366. strategy controller Function init
- 1367. strategy controller Function load strategy parameters
- 1368. strategy controller Function apply to config
- 1369. strategy controller Function clone
- 1370. strategy controller Function compare with
- 1371. strategy controller Function customize
- 1372. strategy controller Function get available strategies
- 1373. strategy controller Function get concurrent requests
- 1374. strategy controller Function get max depth
- 1375. strategy controller Function get max pages
- 1376. strategy controller Function get parameters
- 1377. strategy controller Function get recommended strategy for target
- 1378. strategy controller Function get requests per second
- 1379. strategy controller Function get strategy description
- 1380. strategy controller Function get strategy name
- 1381. strategy controller Function get strategy summary
- 1382. strategy controller Function is aggressive
- 1383. strategy controller Function is stealth
- 1384. strategy controller Function reset customizations
1. aiva common config Function get settings
flowchart TB
n1([開始])
n2([結束])
n3[return Settings()]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return Settings()]
n1 --> n3
n3 --> n2
2. aiva common models Function non negative
flowchart TB
n1([開始])
n2([結束])
n3{if v < 0}
n4[raise ValueError('rate limit must be non-...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if v &lt; 0}
n4[raise ValueError(&#39;rate limit must be non-...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
3. aiva common mq Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化內存 Broker。']
n4[self._queues: dict[str, asyncio.Queue[bytes]&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化內存 Broker。&#39;]
n4[self._queues: dict[str, asyncio.Queue[bytes]&...]
n1 --> n3
n3 --> n4
n4 --> n2
4. aiva common schemas ai Function calculate base score
flowchart TB
n1([開始])
n2([結束])
n3['計算 CVSS v3.1 基本分數']
n4[av_weights = {'N': 0.85, &am...]
n5[ac_weights = {'L': 0.77, &am...]
n6{if self.scope == 'C'}
n7[pr_weights = {'N': 0.85, &am...]
n8[pr_weights = {'N': 0.85, &am...]
n9[]
n10[ui_weights = {'N': 0.85, &am...]
n11[cia_weights = {'N': 0.0, &am...]
n12[impact = 1 - (1 - cia_weights...]
n13{if self.scope == 'C'}
n14[impact_adjusted = 7.52 * (impact - 0.0...]
n15[impact_adjusted = 6.42 * impact]
n16[]
n17[exploitability = 8.22 * av_weights[se...]
n18{if impact_adjusted <= 0}
n19[return 0.0]
n20[]
n21{if self.scope == 'U'}
n22[base = impact_adjusted + ex...]
n23[base = 1.08 * (impact_adjus...]
n24[]
n25[return min(10.0, round(base, 1))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n24
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算 CVSS v3.1 基本分數&#39;]
n4[av_weights = {&#39;N&#39;: 0.85, &am...]
n5[ac_weights = {&#39;L&#39;: 0.77, &am...]
n6{if self.scope == &#39;C&#39;}
n7[pr_weights = {&#39;N&#39;: 0.85, &am...]
n8[pr_weights = {&#39;N&#39;: 0.85, &am...]
n9[]
n10[ui_weights = {&#39;N&#39;: 0.85, &am...]
n11[cia_weights = {&#39;N&#39;: 0.0, &am...]
n12[impact = 1 - (1 - cia_weights...]
n13{if self.scope == &#39;C&#39;}
n14[impact_adjusted = 7.52 * (impact - 0.0...]
n15[impact_adjusted = 6.42 * impact]
n16[]
n17[exploitability = 8.22 * av_weights[se...]
n18{if impact_adjusted &lt;= 0}
n19[return 0.0]
n20[]
n21{if self.scope == &#39;U&#39;}
n22[base = impact_adjusted + ex...]
n23[base = 1.08 * (impact_adjus...]
n24[]
n25[return min(10.0, round(base, 1))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n24
n23 --> n24
n24 --> n25
n25 --> n2
5. aiva common schemas ai Function validate plan id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('plan_')}
n4[raise ValueError("plan_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;plan_&#39;)}
n4[raise ValueError(&quot;plan_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
6. aiva common schemas ai Function validate status
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'completed', &...]
n4{if v not in allowed}
n5[raise ValueError(f'Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;completed&#39;, &...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
7. aiva common schemas ai Function validate training id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('training_...}
n4[raise ValueError("training_id must start wit...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;training_&#3...}
n4[raise ValueError(&quot;training_id must start wit...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
8. aiva common schemas base Function non negative
flowchart TB
n1([開始])
n2([結束])
n3{if v < 0}
n4[raise ValueError('rate limit must be non-...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if v &lt; 0}
n4[raise ValueError(&#39;rate limit must be non-...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
9. aiva common schemas enhanced Function to sarif result
flowchart TB
n1([開始])
n2([結束])
n3['轉換為 SARIF 結果格式\n\n Returns:\n ...]
n4{if self.sarif_result}
n5[return self.sarif_result]
n6[]
n7[level_mapping = {Severity.CRITICAL: ...]
n8[locations = []]
n9{if self.target.url}
n10[locations.append(SARIFLocation(uri=str(self.t...]
n11[]
n12[return SARIFResult(rule_id=self.vulne...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為 SARIF 結果格式\n\n Returns:\n ...]
n4{if self.sarif_result}
n5[return self.sarif_result]
n6[]
n7[level_mapping = {Severity.CRITICAL: ...]
n8[locations = []]
n9{if self.target.url}
n10[locations.append(SARIFLocation(uri=str(self.t...]
n11[]
n12[return SARIFResult(rule_id=self.vulne...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
10. aiva common schemas enhanced Function validate finding id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('finding_'...}
n4[raise ValueError("finding_id must start with...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;finding_&#39...}
n4[raise ValueError(&quot;finding_id must start with...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
11. aiva common schemas enhanced Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
12. aiva common schemas findings Function validate finding id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('finding_'...}
n4[raise ValueError("finding_id must start with...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;finding_&#39...}
n4[raise ValueError(&quot;finding_id must start with...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
13. aiva common schemas findings Function validate status
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'confirmed', &...]
n4{if v not in allowed}
n5[raise ValueError(f'Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;confirmed&#39;, &...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
14. aiva common schemas findings Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
15. aiva common schemas system Function validate session id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('session_'...}
n4[raise ValueError("session_id must start with...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;session_&#39...}
n4[raise ValueError(&quot;session_id must start with...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
16. aiva common schemas system Function validate status
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'active', &...]
n4{if v not in allowed}
n5[raise ValueError(f'Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;active&#39;, &&#...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
17. aiva common schemas tasks Function validate priority
flowchart TB
n1([開始])
n2([結束])
n3{if not 1 <= v <= 10}
n4[raise ValueError('priority must be betwee...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not 1 &lt;= v &lt;= 10}
n4[raise ValueError(&#39;priority must be betwee...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
18. aiva common schemas tasks Function validate strategy
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'quick', &...]
n4{if v not in allowed}
n5[raise ValueError(f'Invalid strategy: ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;quick&#39;, &...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;Invalid strategy: ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
19. aiva common schemas tasks Function validate targets
flowchart TB
n1([開始])
n2([結束])
n3{if not v}
n4[raise ValueError('At least one target req...]
n5[]
n6{if len(v) > 100}
n7[raise ValueError('Too many targets (m...]
n8[]
n9[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v}
n4[raise ValueError(&#39;At least one target req...]
n5[]
n6{if len(v) &gt; 100}
n7[raise ValueError(&#39;Too many targets (m...]
n8[]
n9[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
20. aiva common schemas tasks Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
21. aiva common schemas telemetry Function record early stopping
flowchart TB
n1([開始])
n2([結束])
n3['記錄提前停止']
n4[self.early_stopping = EarlyStoppingInfo(re...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄提前停止&#39;]
n4[self.early_stopping = EarlyStoppingInfo(re...]
n1 --> n3
n3 --> n4
n4 --> n2
22. aiva common schemas telemetry Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄結構化錯誤']
n4[error = ErrorRecord(category...]
n5[self.error_records.append(error)]
n6[self.errors.append(f'[{category....]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄結構化錯誤&#39;]
n4[error = ErrorRecord(category...]
n5[self.error_records.append(error)]
n6[self.errors.append(f&#39;[{category....]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
23. aiva common schemas telemetry Function record oast callback
flowchart TB
n1([開始])
n2([結束])
n3['記錄 OAST 回調']
n4[callback = OastCallbackDetail(c...]
n5[self.oast_callbacks.append(callback)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 OAST 回調&#39;]
n4[callback = OastCallbackDetail(c...]
n5[self.oast_callbacks.append(callback)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
24. aiva common schemas telemetry Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式 (擴展版)']
n4[details = super().to_details(f...]
n5{if self.error_records}
n6[error_summary: dict[str, int] = {}]
n7{for err in self.error_records}
n8[category = err.category.value]
n9[error_summary[category] = error_summary.get(c...]
n10[]
n11[details['error_categories' ...]
n12[details['error_details'] ...]
n13[]
n14{if self.oast_callbacks}
n15[details['oast_callbacks_count'...]
n16[callback_summary: dict[str, int] = {}]
n17{for cb in self.oast_callbacks}
n18[callback_summary[cb.callback_type] = callback_sum...]
n19[]
n20[details['oast_callback_types'...]
n21[]
n22{if self.early_stopping}
n23[details['early_stopping']...]
n24[]
n25{if self.adaptive_behavior}
n26[details['adaptive_behavior'...]
n27[]
n28[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n7
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n21
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n17
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式 (擴展版)&#39;]
n4[details = super().to_details(f...]
n5{if self.error_records}
n6[error_summary: dict[str, int] = {}]
n7{for err in self.error_records}
n8[category = err.category.value]
n9[error_summary[category] = error_summary.get(c...]
n10[]
n11[details[&#39;error_categories&#39;	...]
n12[details[&#39;error_details&#39;] ...]
n13[]
n14{if self.oast_callbacks}
n15[details[&#39;oast_callbacks_count&#39...]
n16[callback_summary: dict[str, int] = {}]
n17{for cb in self.oast_callbacks}
n18[callback_summary[cb.callback_type] = callback_sum...]
n19[]
n20[details[&#39;oast_callback_types&#39;...]
n21[]
n22{if self.early_stopping}
n23[details[&#39;early_stopping&#39;]...]
n24[]
n25{if self.adaptive_behavior}
n26[details[&#39;adaptive_behavior&#39;&#...]
n27[]
n28[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n7
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n21
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n17
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n27
n27 --> n28
n28 --> n2
25. aiva common schemas telemetry Function update adaptive behavior
flowchart TB
n1([開始])
n2([結束])
n3['更新自適應行為信息']
n4{if self.adaptive_behavior is None}
n5[self.adaptive_behavior = AdaptiveBehaviorInfo...]
n6[]
n7{if initial_batch_size is not None}
n8[self.adaptive_behavior.initial_batch_size = initial_batch...]
n9[]
n10{if final_batch_size is not None}
n11[self.adaptive_behavior.final_batch_size = final_batch_size]
n12[]
n13{if rate_adjustments is not None}
n14[self.adaptive_behavior.rate_adjustments = rate_adjustments]
n15[]
n16{if protection_detections is no...}
n17[self.adaptive_behavior.protection_detections = protection...]
n18[]
n19{if bypass_attempts is not None}
n20[self.adaptive_behavior.bypass_attempts = bypass_attempts]
n21[]
n22{if success_rate is not None}
n23[self.adaptive_behavior.success_rate = success_rate]
n24[]
n25{if details}
n26[self.adaptive_behavior.details.update(details)]
n27[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新自適應行為信息&#39;]
n4{if self.adaptive_behavior is None}
n5[self.adaptive_behavior = AdaptiveBehaviorInfo...]
n6[]
n7{if initial_batch_size is not None}
n8[self.adaptive_behavior.initial_batch_size = initial_batch...]
n9[]
n10{if final_batch_size is not None}
n11[self.adaptive_behavior.final_batch_size = final_batch_size]
n12[]
n13{if rate_adjustments is not None}
n14[self.adaptive_behavior.rate_adjustments = rate_adjustments]
n15[]
n16{if protection_detections is no...}
n17[self.adaptive_behavior.protection_detections = protection...]
n18[]
n19{if bypass_attempts is not None}
n20[self.adaptive_behavior.bypass_attempts = bypass_attempts]
n21[]
n22{if success_rate is not None}
n23[self.adaptive_behavior.success_rate = success_rate]
n24[]
n25{if details}
n26[self.adaptive_behavior.details.update(details)]
n27[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n27
n27 --> n2
26. aiva common schemas telemetry Function validate event type
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'http', &#...]
n4{if v not in allowed}
n5[raise ValueError(f'Invalid event_type: ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;http&#39;, &#...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;Invalid event_type: &#...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
27. aiva common schemas telemetry Function validate status
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'active', &...]
n4{if v not in allowed}
n5[raise ValueError(f'Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;active&#39;, &&#...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;Invalid status: {...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
28. aiva common utils dedup dedupe Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n Initialize deduplication tracker.\...]
n4{if ttl_days is None or ttl_day...}
n5[self._ttl_seconds = 0.0]
n6[days: float = float(ttl_days)]
n7[self._ttl_seconds = max(days, 0.0) * 864...]
n8[]
n9[self._lock = threading.Lock()]
n10{if isinstance(db_path, Path)}
n11[db_path.parent.mkdir(parents=True, exist_ok=True)]
n12[db_location = str(db_path)]
n13{if isinstance(db_path, str) an...}
n14[Path(db_path).parent.mkdir(parents=True, exis...]
n15[db_location = db_path]
n16{if db_path}
n17[db_location = str(db_path)]
n18[db_location = ':memory:']
n19[]
n20[]
n21[]
n22[self._conn = sqlite3.connect(db_l...]
n23[self._finalizer = weakref.finalize(sel...]
n24[try]
n25[self._conn.execute('PRAGMA journal_mode=W...]
n26[]
n27[except sqlite3.Data...]
n28[logger.warning('Failed to enable WAL mode...]
n29[self._conn.execute('\n CREATE ...]
n30[self._conn.execute('CREATE INDEX IF NOT E...]
n31[logger.debug('Initialized DeDup with db=%...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n21
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n20
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n24 --> n27
n25 --> n26
n26 --> n29
n27 --> n28
n28 --> n26
n29 --> n30
n30 --> n31
n31 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Initialize deduplication tracker.\...]
n4{if ttl_days is None or ttl_day...}
n5[self._ttl_seconds = 0.0]
n6[days: float = float(ttl_days)]
n7[self._ttl_seconds = max(days, 0.0) * 864...]
n8[]
n9[self._lock = threading.Lock()]
n10{if isinstance(db_path, Path)}
n11[db_path.parent.mkdir(parents=True, exist_ok=True)]
n12[db_location = str(db_path)]
n13{if isinstance(db_path, str) an...}
n14[Path(db_path).parent.mkdir(parents=True, exis...]
n15[db_location = db_path]
n16{if db_path}
n17[db_location = str(db_path)]
n18[db_location = &#39;:memory:&#39;]
n19[]
n20[]
n21[]
n22[self._conn = sqlite3.connect(db_l...]
n23[self._finalizer = weakref.finalize(sel...]
n24[try]
n25[self._conn.execute(&#39;PRAGMA journal_mode=W...]
n26[]
n27[except sqlite3.Data...]
n28[logger.warning(&#39;Failed to enable WAL mode...]
n29[self._conn.execute(&#39;\n CREATE ...]
n30[self._conn.execute(&#39;CREATE INDEX IF NOT E...]
n31[logger.debug(&#39;Initialized DeDup with db=%...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n21
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n20
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n24 --> n27
n25 --> n26
n26 --> n29
n27 --> n28
n28 --> n26
n29 --> n30
n30 --> n31
n31 --> n2
29. aiva common utils dedup dedupe Function prune
flowchart TB
n1([開始])
n2([結束])
n3['Remove expired fingerprints.']
n4{if self._ttl_seconds > 0}
n5[deleted = self._conn.execute('...]
n6{if deleted > 0}
n7[logger.debug('Pruned %d expired fingerpri...]
n8[]
n9[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n9
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Remove expired fingerprints.&#39;]
n4{if self._ttl_seconds &gt; 0}
n5[deleted = self._conn.execute(&#39;...]
n6{if deleted &gt; 0}
n7[logger.debug(&#39;Pruned %d expired fingerpri...]
n8[]
n9[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n9
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
30. aiva common utils dedup dedupe Function clear
flowchart TB
n1([開始])
n2([結束])
n3['\n Clear all fingerprints from the da...]
n4[with self._lock]
n5[self._conn.execute('DELETE FROM fingerpri...]
n6[logger.info('Cleared all fingerprints fro...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Clear all fingerprints from the da...]
n4[with self._lock]
n5[self._conn.execute(&#39;DELETE FROM fingerpri...]
n6[logger.info(&#39;Cleared all fingerprints fro...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
31. aiva common utils dedup dedupe Function close
flowchart TB
n1([開始])
n2([結束])
n3['\n Close the underlying SQLite connec...]
n4[with self._lock]
n5{if self._finalizer.alive}
n6[self._finalizer()]
n7[logger.debug('Closed DeDup database conne...]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Close the underlying SQLite connec...]
n4[with self._lock]
n5{if self._finalizer.alive}
n6[self._finalizer()]
n7[logger.debug(&#39;Closed DeDup database conne...]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n2
32. aiva common utils dedup dedupe Function compute fingerprint
flowchart TB
n1([開始])
n2([結束])
n3['\n Compute a deterministic fingerprint fo...]
n4[vector = item.get('vector', &...]
n5[base_obj = {'target': item.g...]
n6[mode = item.get('mode')]
n7{if mode}
n8[base_obj['mode'] = mode]
n9[]
n10[base = json.dumps(base_obj,...]
n11[return hashlib.sha256(base.encode('ut...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Compute a deterministic fingerprint fo...]
n4[vector = item.get(&#39;vector&#39;, &...]
n5[base_obj = {&#39;target&#39;: item.g...]
n6[mode = item.get(&#39;mode&#39;)]
n7{if mode}
n8[base_obj[&#39;mode&#39;] = mode]
n9[]
n10[base = json.dumps(base_obj,...]
n11[return hashlib.sha256(base.encode(&#39;ut...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
33. aiva common utils dedup dedupe Function count
flowchart TB
n1([開始])
n2([結束])
n3['\n Get the number of fingerprints cur...]
n4[with self._lock]
n5[self._prune(time.time())]
n6[row = self._conn.execute('...]
n7[return row[0] if row else 0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Get the number of fingerprints cur...]
n4[with self._lock]
n5[self._prune(time.time())]
n6[row = self._conn.execute(&#39;...]
n7[return row[0] if row else 0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
34. aiva common utils dedup dedupe Function mark
flowchart TB
n1([開始])
n2([結束])
n3['\n Explicitly mark an item as seen wi...]
n4[digest = compute_fingerprint(...]
n5[now = time.time()]
n6[expires = now + self._ttl_seco...]
n7[with self._lock]
n8[self._conn.execute('INSERT OR REPLACE INT...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Explicitly mark an item as seen wi...]
n4[digest = compute_fingerprint(...]
n5[now = time.time()]
n6[expires = now + self._ttl_seco...]
n7[with self._lock]
n8[self._conn.execute(&#39;INSERT OR REPLACE INT...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
35. aiva common utils dedup dedupe Function seen before
flowchart TB
n1([開始])
n2([結束])
n3['\n Check if item has been seen before...]
n4[digest = compute_fingerprint(...]
n5[now = time.time()]
n6[with self._lock]
n7[self._prune(now)]
n8{if self._ttl_seconds > 0}
n9[row = self._conn.execute('...]
n10[row = self._conn.execute('...]
n11[]
n12{if row}
n13[return True]
n14[]
n15[expires = now + self._ttl_seco...]
n16[self._conn.execute('INSERT OR REPLACE INT...]
n17[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Check if item has been seen before...]
n4[digest = compute_fingerprint(...]
n5[now = time.time()]
n6[with self._lock]
n7[self._prune(now)]
n8{if self._ttl_seconds &gt; 0}
n9[row = self._conn.execute(&#39;...]
n10[row = self._conn.execute(&#39;...]
n11[]
n12{if row}
n13[return True]
n14[]
n15[expires = now + self._ttl_seco...]
n16[self._conn.execute(&#39;INSERT OR REPLACE INT...]
n17[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
36. aiva common utils ids Function new id
flowchart TB
n1([開始])
n2([結束])
n3['Generate a short unique identifier with a gi...]
n4[return f'{prefix}-{uuid.uuid4&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Generate a short unique identifier with a gi...]
n4[return f&#39;{prefix}-{uuid.uuid4&...]
n1 --> n3
n3 --> n4
n4 --> n2
37. aiva common utils logging Function get logger
flowchart TB
n1([開始])
n2([結束])
n3['Return a configured logger for the given mod...]
n4[logger = logging.getLogger(na...]
n5{if not logger.handlers}
n6[logger.setLevel(logging.INFO)]
n7[handler = logging.StreamHandle...]
n8[formatter = logging.Formatter(fm...]
n9[handler.setFormatter(formatter)]
n10[logger.addHandler(handler)]
n11[]
n12[return logger]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Return a configured logger for the given mod...]
n4[logger = logging.getLogger(na...]
n5{if not logger.handlers}
n6[logger.setLevel(logging.INFO)]
n7[handler = logging.StreamHandle...]
n8[formatter = logging.Formatter(fm...]
n9[handler.setFormatter(formatter)]
n10[logger.addHandler(handler)]
n11[]
n12[return logger]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
38. aiva common utils network backoff Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n Initialize RetryingAsyncClient.\n\...]
n4[super().__init__(*args, **kwargs)]
n5[self._max_retries = max(0, int(retries))]
n6[self._backoff = backoff if backoff i...]
n7{if retry_on is None}
n8[retry_excs: Sequence[type[BaseException]]...]
n9[retry_excs = tuple(retry_on)]
n10[]
n11[self._retry_exceptions: tuple[type[BaseException&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Initialize RetryingAsyncClient.\n\...]
n4[super().__init__(*args, **kwargs)]
n5[self._max_retries = max(0, int(retries))]
n6[self._backoff = backoff if backoff i...]
n7{if retry_on is None}
n8[retry_excs: Sequence[type[BaseException]]...]
n9[retry_excs = tuple(retry_on)]
n10[]
n11[self._retry_exceptions: tuple[type[BaseException&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 --> n2
39. aiva common utils network backoff Function resolve backoff
flowchart TB
n1([開始])
n2([結束])
n3['\n Evaluate backoff callable for attempt ...]
n4{if backoff is None}
n5[return 0.0]
n6[]
n7[try]
n8[delay = backoff(attempt=atte...]
n9[]
n10[except TypeError]
n11[delay = backoff(attempt)]
n12[except Exception]
n13[logger.warning('Backoff callable %r faile...]
n14[return 0.0]
n15[try]
n16[return max(0.0, float(delay))]
n17[]
n18[except (TypeError, ...]
n19[logger.warning('Backoff callable %r retur...]
n20[return 0.0]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n10
n7 --> n12
n8 --> n9
n9 --> n15
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 --> n9
n15 --> n16
n15 --> n18
n16 --> n17
n17 --> n2
n18 --> n19
n19 --> n20
n20 --> n17
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Evaluate backoff callable for attempt ...]
n4{if backoff is None}
n5[return 0.0]
n6[]
n7[try]
n8[delay = backoff(attempt=atte...]
n9[]
n10[except TypeError]
n11[delay = backoff(attempt)]
n12[except Exception]
n13[logger.warning(&#39;Backoff callable %r faile...]
n14[return 0.0]
n15[try]
n16[return max(0.0, float(delay))]
n17[]
n18[except (TypeError, ...]
n19[logger.warning(&#39;Backoff callable %r retur...]
n20[return 0.0]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n10
n7 --> n12
n8 --> n9
n9 --> n15
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 --> n9
n15 --> n16
n15 --> n18
n16 --> n17
n17 --> n2
n18 --> n19
n19 --> n20
n20 --> n17
40. aiva common utils network backoff Function jitter backoff
flowchart TB
n1([開始])
n2([結束])
n3['\n Return a jittered exponential delay fo...]
n4[t = min(max_time, base *...]
n5[return t * (0.5 + random.random())]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Return a jittered exponential delay fo...]
n4[t = min(max_time, base *...]
n5[return t * (0.5 + random.random())]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
41. aiva common utils network ratelimit Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n Initialize rate limiter.\n\n ...]
n4[self.global_rps = float(global_rps)]
n5[self.per_host_rps = float(per_host_rps)]
n6[burst_g = max(1, int(self.glob...]
n7[burst_h = max(1, int(self.per_...]
n8[self.global_bucket = TokenBucket(self.glo...]
n9[self.default_host_burst = burst_h]
n10[self.host_buckets: dict[str, TokenBucket] = {...]
n11[self.host_overrides: dict[str, float] = {}]
n12[self.host_last_used: dict[str, float] = {}]
n13[self.jitter = jitter_ms / 1000.0]
n14[self.state_file = Path(state_file) if ...]
n15[self.state_lock = threading.Lock()]
n16[self.config_lock = threading.Lock()]
n17[self._host_usage_lock = threading.Lock()]
n18[self.min_global_rps = 0.05]
n19[self.max_global_rps = max(self.global_rps ...]
n20[self.min_per_host_rps = 0.05]
n21[self.max_per_host_rps = max(self.per_host_rp...]
n22[self._state_write_interval = 1.0]
n23[self._next_state_write = 0.0]
n24[try]
n25[ttl_val = float(host_ttl) if h...]
n26[]
n27[except (TypeError, ...]
n28[ttl_val = None]
n29[self.host_ttl = ttl_val if ttl_val a...]
n30[try]
n31[cleanup_val = float(cleanup_interv...]
n32[]
n33[except (TypeError, ...]
n34[cleanup_val = 60.0]
n35[self._cleanup_interval = cleanup_val if clean...]
n36[self._next_cleanup = time.monotonic() + s...]
n37[self._cooldown_until: dict[str, float] = {...]
n38[self._log = logging.getLogger(__...]
n39{if self.state_file}
n40[self._load_state()]
n41[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n24 --> n27
n25 --> n26
n26 --> n29
n27 --> n28
n28 --> n26
n29 --> n30
n30 --> n31
n30 --> n33
n31 --> n32
n32 --> n35
n33 --> n34
n34 --> n32
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n41
n40 --> n41
n41 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Initialize rate limiter.\n\n ...]
n4[self.global_rps = float(global_rps)]
n5[self.per_host_rps = float(per_host_rps)]
n6[burst_g = max(1, int(self.glob...]
n7[burst_h = max(1, int(self.per_...]
n8[self.global_bucket = TokenBucket(self.glo...]
n9[self.default_host_burst = burst_h]
n10[self.host_buckets: dict[str, TokenBucket] = {...]
n11[self.host_overrides: dict[str, float] = {}]
n12[self.host_last_used: dict[str, float] = {}]
n13[self.jitter = jitter_ms / 1000.0]
n14[self.state_file = Path(state_file) if ...]
n15[self.state_lock = threading.Lock()]
n16[self.config_lock = threading.Lock()]
n17[self._host_usage_lock = threading.Lock()]
n18[self.min_global_rps = 0.05]
n19[self.max_global_rps = max(self.global_rps ...]
n20[self.min_per_host_rps = 0.05]
n21[self.max_per_host_rps = max(self.per_host_rp...]
n22[self._state_write_interval = 1.0]
n23[self._next_state_write = 0.0]
n24[try]
n25[ttl_val = float(host_ttl) if h...]
n26[]
n27[except (TypeError, ...]
n28[ttl_val = None]
n29[self.host_ttl = ttl_val if ttl_val a...]
n30[try]
n31[cleanup_val = float(cleanup_interv...]
n32[]
n33[except (TypeError, ...]
n34[cleanup_val = 60.0]
n35[self._cleanup_interval = cleanup_val if clean...]
n36[self._next_cleanup = time.monotonic() + s...]
n37[self._cooldown_until: dict[str, float] = {&#...]
n38[self._log = logging.getLogger(__...]
n39{if self.state_file}
n40[self._load_state()]
n41[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n24 --> n27
n25 --> n26
n26 --> n29
n27 --> n28
n28 --> n26
n29 --> n30
n30 --> n31
n30 --> n33
n31 --> n32
n32 --> n35
n33 --> n34
n34 --> n32
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n41
n40 --> n41
n41 --> n2
42. aiva common utils network ratelimit Function apply rate
flowchart TB
n1([開始])
n2([結束])
n3['Apply new rate to a bucket.']
n4[burst = max(1, int(rate))]
n5[with bucket.lock]
n6[bucket.rate = rate]
n7[bucket.capacity = burst]
n8[bucket.tokens = min(bucket.capacity,...]
n9[bucket.updated = time.monotonic()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Apply new rate to a bucket.&#39;]
n4[burst = max(1, int(rate))]
n5[with bucket.lock]
n6[bucket.rate = rate]
n7[bucket.capacity = burst]
n8[bucket.tokens = min(bucket.capacity,...]
n9[bucket.updated = time.monotonic()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
43. aiva common utils network ratelimit Function bucket for
flowchart TB
n1([開始])
n2([結束])
n3['Get or create Token Bucket for a host.&&...]
n4[self._maybe_cleanup_hosts()]
n5[b = self.host_buckets.ge...]
n6{if b is None}
n7[rate = self._host_rate(host...]
n8[burst = max(1, int(rate))]
n9[b = TokenBucket(rate, bu...]
n10[self.host_buckets[host] = b]
n11[]
n12[self._touch_host(host)]
n13[return b]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Get or create Token Bucket for a host.&&...]
n4[self._maybe_cleanup_hosts()]
n5[b = self.host_buckets.ge...]
n6{if b is None}
n7[rate = self._host_rate(host...]
n8[burst = max(1, int(rate))]
n9[b = TokenBucket(rate, bu...]
n10[self.host_buckets[host] = b]
n11[]
n12[self._touch_host(host)]
n13[return b]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
44. aiva common utils network ratelimit Function bucket state
flowchart TB
n1([開始])
n2([結束])
n3['Capture current bucket state for persistence...]
n4[with bucket.lock]
n5[elapsed = max(0.0, mono_now - ...]
n6[updated_wall = max(0.0, wall_now - ...]
n7[return {'rate': rate, &&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Capture current bucket state for persistence...]
n4[with bucket.lock]
n5[elapsed = max(0.0, mono_now - ...]
n6[updated_wall = max(0.0, wall_now - ...]
n7[return {&#39;rate&#39;: rate, &&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
45. aiva common utils network ratelimit Function host rate
flowchart TB
n1([開始])
n2([結束])
n3['Get the rate limit for a specific host.&...]
n4[return self.host_overrides.get(host, ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Get the rate limit for a specific host.&...]
n4[return self.host_overrides.get(host, ...]
n1 --> n3
n3 --> n4
n4 --> n2
46. aiva common utils network ratelimit Function load state
flowchart TB
n1([開始])
n2([結束])
n3['Load state from persistent storage.&#...]
n4{if not self.state_file or not ...}
n5[return]
n6[]
n7[with self.stat...]
n8[try]
n9[with self.stat...]
n10[data = json.load(fh)]
n11[]
n12[except (OSError, js...]
n13[logger.warning('Failed to load rate limit...]
n14[return]
n15[now_wall = time.time()]
n16[now_mono = time.monotonic()]
n17[saved_at = data.get('saved_at'...]
n18[try]
n19[saved_at_f = float(saved_at) if s...]
n20[]
n21[except (TypeError, ...]
n22[saved_at_f = 0.0]
n23[base_elapsed = max(0.0, now_wall - ...]
n24[global_state = data.get('global&#...]
n25{if isinstance(global_state, dict)}
n26[rate_val = global_state.get('ra...]
n27[try]
n28[rate = float(rate_val)]
n29[]
n30[except (TypeError, ...]
n31[rate = self.global_rps]
n32[self._set_global_rate(rate)]
n33[tokens_val = global_state.get('to...]
n34[try]
n35[tokens = float(tokens_val)]
n36[]
n37[except (TypeError, ...]
n38[tokens = self.global_bucket.t...]
n39[updated_val = global_state.get('up...]
n40[try]
n41[updated_at = float(updated_val) i...]
n42[]
n43[except (TypeError, ...]
n44[updated_at = None]
n45[elapsed = base_elapsed if upda...]
n46[with self.glob...]
n47[refill = tokens + elapsed * s...]
n48[self.global_bucket.tokens = min(self.global_buck...]
n49[self.global_bucket.updated = max(now_mono - elaps...]
n50[]
n51[self.host_buckets.clear()]
n52[with self._hos...]
n53[self.host_last_used.clear()]
n54[overrides = data.get('host_overr...]
n55{if isinstance(overrides, dict)}
n56[new_overrides: dict[str, float] = {}]
n57{for (host, value) in overrides.items()}
n58[try]
n59[new_overrides[str(host)] = float(valu...]
n60[]
n61[except (TypeError, ...]
n62[continue]
n63[]
n64[self.host_overrides = new_overrides]
n65[self.host_overrides = {}]
n66[]
n67[per_host_base = data.get('per_host_r...]
n68{if per_host_base is not None}
n69[with contextli...]
n70[self._set_per_host_base(float(per_host_base)&...]
n71[]
n72[hosts = data.get('hosts')]
n73{if isinstance(hosts, dict)}
n74{for (host, bucket_data) in hosts.items()}
n75{if not isinstance(bucket_data,...}
n76[continue]
n77[]
n78[rate_val = bucket_data.get('rat...]
n79[try]
n80[rate = float(rate_val)]
n81[]
n82[except (TypeError, ...]
n83[rate = self._host_rate(host...]
n84[burst = max(1, int(rate))]
n85[bucket = TokenBucket(rate, bu...]
n86[tokens_val = bucket_data.get('tok...]
n87[try]
n88[tokens = float(tokens_val)]
n89[]
n90[except (TypeError, ...]
n91[tokens = float(burst)]
n92[updated_val = bucket_data.get('upd...]
n93[try]
n94[updated_at = float(updated_val) i...]
n95[]
n96[except (TypeError, ...]
n97[updated_at = None]
n98[elapsed = base_elapsed if upda...]
n99[refill = tokens + elapsed * r...]
n100[bucket.tokens = min(bucket.capacity,...]
n101[bucket.updated = max(now_mono - elaps...]
n102[self.host_buckets[str(host)] = bucket]
n103[self._touch_host(str(host), now_mono)]
n104[]
n105[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n8 --> n12
n9 --> n10
n10 --> n11
n11 --> n15
n12 --> n13
n13 --> n14
n14 --> n11
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n18 --> n21
n19 --> n20
n20 --> n23
n21 --> n22
n22 --> n20
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n50
n26 --> n27
n27 --> n28
n27 --> n30
n28 --> n29
n29 --> n32
n30 --> n31
n31 --> n29
n32 --> n33
n33 --> n34
n34 --> n35
n34 --> n37
n35 --> n36
n36 --> n39
n37 --> n38
n38 --> n36
n39 --> n40
n40 --> n41
n40 --> n43
n41 --> n42
n42 --> n45
n43 --> n44
n44 --> n42
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 -->|Yes| n56
n55 -->|No| n65
n56 --> n57
n57 -->|Yes| n58
n57 -->|No| n63
n58 --> n59
n58 --> n61
n59 --> n60
n60 --> n57
n61 --> n62
n62 --> n60
n63 --> n64
n64 --> n66
n65 --> n66
n66 --> n67
n67 --> n68
n68 -->|Yes| n69
n68 -->|No| n71
n69 --> n70
n70 --> n71
n71 --> n72
n72 --> n73
n73 -->|Yes| n74
n73 -->|No| n105
n74 -->|Yes| n75
n74 -->|No| n104
n75 -->|Yes| n76
n75 -->|No| n77
n76 --> n77
n77 --> n78
n78 --> n79
n79 --> n80
n79 --> n82
n80 --> n81
n81 --> n84
n82 --> n83
n83 --> n81
n84 --> n85
n85 --> n86
n86 --> n87
n87 --> n88
n87 --> n90
n88 --> n89
n89 --> n92
n90 --> n91
n91 --> n89
n92 --> n93
n93 --> n94
n93 --> n96
n94 --> n95
n95 --> n98
n96 --> n97
n97 --> n95
n98 --> n99
n99 --> n100
n100 --> n101
n101 --> n102
n102 --> n103
n103 --> n74
n104 --> n105
n105 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Load state from persistent storage.&#...]
n4{if not self.state_file or not ...}
n5[return]
n6[]
n7[with self.stat...]
n8[try]
n9[with self.stat...]
n10[data = json.load(fh)]
n11[]
n12[except (OSError, js...]
n13[logger.warning(&#39;Failed to load rate limit...]
n14[return]
n15[now_wall = time.time()]
n16[now_mono = time.monotonic()]
n17[saved_at = data.get(&#39;saved_at&#39...]
n18[try]
n19[saved_at_f = float(saved_at) if s...]
n20[]
n21[except (TypeError, ...]
n22[saved_at_f = 0.0]
n23[base_elapsed = max(0.0, now_wall - ...]
n24[global_state = data.get(&#39;global&#...]
n25{if isinstance(global_state, dict)}
n26[rate_val = global_state.get(&#39;ra...]
n27[try]
n28[rate = float(rate_val)]
n29[]
n30[except (TypeError, ...]
n31[rate = self.global_rps]
n32[self._set_global_rate(rate)]
n33[tokens_val = global_state.get(&#39;to...]
n34[try]
n35[tokens = float(tokens_val)]
n36[]
n37[except (TypeError, ...]
n38[tokens = self.global_bucket.t...]
n39[updated_val = global_state.get(&#39;up...]
n40[try]
n41[updated_at = float(updated_val) i...]
n42[]
n43[except (TypeError, ...]
n44[updated_at = None]
n45[elapsed = base_elapsed if upda...]
n46[with self.glob...]
n47[refill = tokens + elapsed * s...]
n48[self.global_bucket.tokens = min(self.global_buck...]
n49[self.global_bucket.updated = max(now_mono - elaps...]
n50[]
n51[self.host_buckets.clear()]
n52[with self._hos...]
n53[self.host_last_used.clear()]
n54[overrides = data.get(&#39;host_overr...]
n55{if isinstance(overrides, dict)}
n56[new_overrides: dict[str, float] = {}]
n57{for (host, value) in overrides.items()}
n58[try]
n59[new_overrides[str(host)] = float(valu...]
n60[]
n61[except (TypeError, ...]
n62[continue]
n63[]
n64[self.host_overrides = new_overrides]
n65[self.host_overrides = {}]
n66[]
n67[per_host_base = data.get(&#39;per_host_r...]
n68{if per_host_base is not None}
n69[with contextli...]
n70[self._set_per_host_base(float(per_host_base)&...]
n71[]
n72[hosts = data.get(&#39;hosts&#39;)]
n73{if isinstance(hosts, dict)}
n74{for (host, bucket_data) in hosts.items()}
n75{if not isinstance(bucket_data,...}
n76[continue]
n77[]
n78[rate_val = bucket_data.get(&#39;rat...]
n79[try]
n80[rate = float(rate_val)]
n81[]
n82[except (TypeError, ...]
n83[rate = self._host_rate(host...]
n84[burst = max(1, int(rate))]
n85[bucket = TokenBucket(rate, bu...]
n86[tokens_val = bucket_data.get(&#39;tok...]
n87[try]
n88[tokens = float(tokens_val)]
n89[]
n90[except (TypeError, ...]
n91[tokens = float(burst)]
n92[updated_val = bucket_data.get(&#39;upd...]
n93[try]
n94[updated_at = float(updated_val) i...]
n95[]
n96[except (TypeError, ...]
n97[updated_at = None]
n98[elapsed = base_elapsed if upda...]
n99[refill = tokens + elapsed * r...]
n100[bucket.tokens = min(bucket.capacity,...]
n101[bucket.updated = max(now_mono - elaps...]
n102[self.host_buckets[str(host)] = bucket]
n103[self._touch_host(str(host), now_mono)]
n104[]
n105[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n8 --> n12
n9 --> n10
n10 --> n11
n11 --> n15
n12 --> n13
n13 --> n14
n14 --> n11
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n18 --> n21
n19 --> n20
n20 --> n23
n21 --> n22
n22 --> n20
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n50
n26 --> n27
n27 --> n28
n27 --> n30
n28 --> n29
n29 --> n32
n30 --> n31
n31 --> n29
n32 --> n33
n33 --> n34
n34 --> n35
n34 --> n37
n35 --> n36
n36 --> n39
n37 --> n38
n38 --> n36
n39 --> n40
n40 --> n41
n40 --> n43
n41 --> n42
n42 --> n45
n43 --> n44
n44 --> n42
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 -->|Yes| n56
n55 -->|No| n65
n56 --> n57
n57 -->|Yes| n58
n57 -->|No| n63
n58 --> n59
n58 --> n61
n59 --> n60
n60 --> n57
n61 --> n62
n62 --> n60
n63 --> n64
n64 --> n66
n65 --> n66
n66 --> n67
n67 --> n68
n68 -->|Yes| n69
n68 -->|No| n71
n69 --> n70
n70 --> n71
n71 --> n72
n72 --> n73
n73 -->|Yes| n74
n73 -->|No| n105
n74 -->|Yes| n75
n74 -->|No| n104
n75 -->|Yes| n76
n75 -->|No| n77
n76 --> n77
n77 --> n78
n78 --> n79
n79 --> n80
n79 --> n82
n80 --> n81
n81 --> n84
n82 --> n83
n83 --> n81
n84 --> n85
n85 --> n86
n86 --> n87
n87 --> n88
n87 --> n90
n88 --> n89
n89 --> n92
n90 --> n91
n91 --> n89
n92 --> n93
n93 --> n94
n93 --> n96
n94 --> n95
n95 --> n98
n96 --> n97
n97 --> n95
n98 --> n99
n99 --> n100
n100 --> n101
n101 --> n102
n102 --> n103
n103 --> n74
n104 --> n105
n105 --> n2
47. aiva common utils network ratelimit Function maybe cleanup hosts
flowchart TB
n1([開始])
n2([結束])
n3['Trigger host cleanup if interval has elapsed...]
n4{if self.host_ttl is None}
n5[return]
n6[]
n7{if now_mono is None}
n8[now_mono = time.monotonic()]
n9[]
n10{if self._cleanup_interval and ...}
n11[return]
n12[]
n13[self.cleanup_expired_hosts(now_mono=now_mono)]
n14{if self._cleanup_interval}
n15[self._next_cleanup = now_mono + self._cle...]
n16[self._next_cleanup = now_mono]
n17[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n17
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Trigger host cleanup if interval has elapsed...]
n4{if self.host_ttl is None}
n5[return]
n6[]
n7{if now_mono is None}
n8[now_mono = time.monotonic()]
n9[]
n10{if self._cleanup_interval and ...}
n11[return]
n12[]
n13[self.cleanup_expired_hosts(now_mono=now_mono)]
n14{if self._cleanup_interval}
n15[self._next_cleanup = now_mono + self._cle...]
n16[self._next_cleanup = now_mono]
n17[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n17
n16 --> n17
n17 --> n2
48. aiva common utils network ratelimit Function scale global
flowchart TB
n1([開始])
n2([結束])
n3['Scale global rate by a factor.']
n4{if factor <= 0}
n5[return]
n6[]
n7[self._set_global_rate(self.global_rps * factor)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Scale global rate by a factor.&#39;]
n4{if factor &lt;= 0}
n5[return]
n6[]
n7[self._set_global_rate(self.global_rps * factor)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
49. aiva common utils network ratelimit Function scale host
flowchart TB
n1([開始])
n2([結束])
n3['Scale specific host rate by a factor.&...]
n4{if factor <= 0}
n5[return]
n6[]
n7[with self.conf...]
n8[current = self.host_overrides....]
n9[new_rate = max(self.min_per_hos...]
n10[self.host_overrides[host] = new_rate]
n11[bucket = self._bucket_for(hos...]
n12[self._apply_rate(bucket, new_rate)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Scale specific host rate by a factor.&&#...]
n4{if factor &lt;= 0}
n5[return]
n6[]
n7[with self.conf...]
n8[current = self.host_overrides....]
n9[new_rate = max(self.min_per_hos...]
n10[self.host_overrides[host] = new_rate]
n11[bucket = self._bucket_for(hos...]
n12[self._apply_rate(bucket, new_rate)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
50. aiva common utils network ratelimit Function scale per host base
flowchart TB
n1([開始])
n2([結束])
n3['Scale per-host base rate by a factor.&...]
n4{if factor <= 0}
n5[return]
n6[]
n7[self._set_per_host_base(self.per_host_rps * factor...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Scale per-host base rate by a factor.&&#...]
n4{if factor &lt;= 0}
n5[return]
n6[]
n7[self._set_per_host_base(self.per_host_rps * factor...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
51. aiva common utils network ratelimit Function set global rate
flowchart TB
n1([開始])
n2([結束])
n3['Update global rate with bounds checking.&...]
n4[clamped = max(self.min_global_...]
n5[burst = max(1, int(clamped))]
n6[with self.glob...]
n7[self.global_rps = clamped]
n8[self.global_bucket.rate = clamped]
n9[self.global_bucket.capacity = burst]
n10[self.global_bucket.tokens = min(self.global_buck...]
n11[self.global_bucket.updated = time.monotonic()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Update global rate with bounds checking.&...]
n4[clamped = max(self.min_global_...]
n5[burst = max(1, int(clamped))]
n6[with self.glob...]
n7[self.global_rps = clamped]
n8[self.global_bucket.rate = clamped]
n9[self.global_bucket.capacity = burst]
n10[self.global_bucket.tokens = min(self.global_buck...]
n11[self.global_bucket.updated = time.monotonic()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
52. aiva common utils network ratelimit Function set per host base
flowchart TB
n1([開始])
n2([結束])
n3['Update per-host base rate with bounds checki...]
n4[clamped = max(self.min_per_hos...]
n5[with self.conf...]
n6[self.per_host_rps = clamped]
n7[self.default_host_burst = max(1, int(clamped)...]
n8[unaffected = [h for h in self.hos...]
n9{for host in unaffected}
n10[self._apply_rate(self.host_buckets[host], cla...]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n9
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Update per-host base rate with bounds checki...]
n4[clamped = max(self.min_per_hos...]
n5[with self.conf...]
n6[self.per_host_rps = clamped]
n7[self.default_host_burst = max(1, int(clamped)...]
n8[unaffected = [h for h in self.hos...]
n9{for host in unaffected}
n10[self._apply_rate(self.host_buckets[host], cla...]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n9
n11 --> n2
53. aiva common utils network ratelimit Function touch host
flowchart TB
n1([開始])
n2([結束])
n3['Update last used timestamp for a host.&&...]
n4{if now_mono is None}
n5[now_mono = time.monotonic()]
n6[]
n7[with self._hos...]
n8[self.host_last_used[host] = now_mono]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Update last used timestamp for a host.&&...]
n4{if now_mono is None}
n5[now_mono = time.monotonic()]
n6[]
n7[with self._hos...]
n8[self.host_last_used[host] = now_mono]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
54. aiva common utils network ratelimit Function write state
flowchart TB
n1([開始])
n2([結束])
n3['Write state to persistent storage.']
n4{if not self.state_file}
n5[return]
n6[]
n7[now_mono = time.monotonic()]
n8{if not force and now_mono < se...}
n9[return]
n10[]
n11[self._maybe_cleanup_hosts(now_mono=now_mono)]
n12[with self.stat...]
n13[now_mono = time.monotonic()]
n14{if not force and now_mono < se...}
n15[return]
n16[]
n17[self._maybe_cleanup_hosts(now_mono=now_mono)]
n18[now_wall = time.time()]
n19[data: dict[str, Any] = {'saved_a...]
n20{for (host, bucket) in list(self.host_bu...}
n21[data['hosts'][host ...]
n22[]
n23[tmp_path = self.state_file.with...]
n24[try]
n25[self.state_file.parent.mkdir(parents=True, exist_o...]
n26[with tmp_path....]
n27[json.dump(data, fh)]
n28[os.replace(tmp_path, self.state_file)]
n29[]
n30[except OSError]
n31[logger.warning('Failed to persist rate li...]
n32[with contextli...]
n33[os.remove(tmp_path)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n20
n22 --> n23
n23 --> n24
n24 --> n25
n24 --> n30
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n2
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n29
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Write state to persistent storage.&#39;]
n4{if not self.state_file}
n5[return]
n6[]
n7[now_mono = time.monotonic()]
n8{if not force and now_mono &lt; se...}
n9[return]
n10[]
n11[self._maybe_cleanup_hosts(now_mono=now_mono)]
n12[with self.stat...]
n13[now_mono = time.monotonic()]
n14{if not force and now_mono &lt; se...}
n15[return]
n16[]
n17[self._maybe_cleanup_hosts(now_mono=now_mono)]
n18[now_wall = time.time()]
n19[data: dict[str, Any] = {&#39;saved_a...]
n20{for (host, bucket) in list(self.host_bu...}
n21[data[&#39;hosts&#39;][host	...]
n22[]
n23[tmp_path = self.state_file.with...]
n24[try]
n25[self.state_file.parent.mkdir(parents=True, exist_o...]
n26[with tmp_path....]
n27[json.dump(data, fh)]
n28[os.replace(tmp_path, self.state_file)]
n29[]
n30[except OSError]
n31[logger.warning(&#39;Failed to persist rate li...]
n32[with contextli...]
n33[os.remove(tmp_path)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n20
n22 --> n23
n23 --> n24
n24 --> n25
n24 --> n30
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n2
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n29
55. aiva common utils network ratelimit Function cleanup expired hosts
flowchart TB
n1([開始])
n2([結束])
n3["Remove hosts that haven't been used...]
n4[ttl = self.host_ttl if ttl...]
n5{if ttl is None}
n6[return]
n7[]
n8[try]
n9[ttl_val = float(ttl)]
n10[]
n11[except (TypeError, ...]
n12[return]
n13{if ttl_val <= 0}
n14[return]
n15[]
n16{if now_mono is None}
n17[now_mono = time.monotonic()]
n18[]
n19[cutoff = now_mono - ttl_val]
n20[with self._hos...]
n21[stale_hosts = [host for host, seen...]
n22{if not stale_hosts}
n23[return]
n24[]
n25[with self._hos...]
n26{for host in stale_hosts}
n27[self.host_last_used.pop(host, None)]
n28[]
n29[with self.conf...]
n30{for host in stale_hosts}
n31[self.host_overrides.pop(host, None)]
n32[]
n33{for host in stale_hosts}
n34[self.host_buckets.pop(host, None)]
n35[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n8 --> n11
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n10
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n26
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n32
n31 --> n30
n32 --> n33
n33 -->|Yes| n34
n33 -->|No| n35
n34 --> n33
n35 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&quot;Remove hosts that haven&#39;t been used...]
n4[ttl = self.host_ttl if ttl...]
n5{if ttl is None}
n6[return]
n7[]
n8[try]
n9[ttl_val = float(ttl)]
n10[]
n11[except (TypeError, ...]
n12[return]
n13{if ttl_val &lt;= 0}
n14[return]
n15[]
n16{if now_mono is None}
n17[now_mono = time.monotonic()]
n18[]
n19[cutoff = now_mono - ttl_val]
n20[with self._hos...]
n21[stale_hosts = [host for host, seen...]
n22{if not stale_hosts}
n23[return]
n24[]
n25[with self._hos...]
n26{for host in stale_hosts}
n27[self.host_last_used.pop(host, None)]
n28[]
n29[with self.conf...]
n30{for host in stale_hosts}
n31[self.host_overrides.pop(host, None)]
n32[]
n33{for host in stale_hosts}
n34[self.host_buckets.pop(host, None)]
n35[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n8 --> n11
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n10
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n26
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n32
n31 --> n30
n32 --> n33
n33 -->|Yes| n34
n33 -->|No| n35
n34 --> n33
n35 --> n2
56. aiva common utils network ratelimit Function load state
flowchart TB
n1([開始])
n2([結束])
n3['Reload state from disk.']
n4[self._load_state()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Reload state from disk.&#39;]
n4[self._load_state()]
n1 --> n3
n3 --> n4
n4 --> n2
57. aiva common utils network ratelimit Function penalize
flowchart TB
n1([開始])
n2([結束])
n3['\n Manually penalize a host by removi...]
n4[b = self._bucket_for(hos...]
n5[with b.lock]
n6[b.tokens = max(0.0, b.tokens - ...]
n7{if status is not None or laten...}
n8[self.update_from_response(host, status_code=status...]
n9[]
n10[self._write_state()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Manually penalize a host by removi...]
n4[b = self._bucket_for(hos...]
n5[with b.lock]
n6[b.tokens = max(0.0, b.tokens - ...]
n7{if status is not None or laten...}
n8[self.update_from_response(host, status_code=status...]
n9[]
n10[self._write_state()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
58. aiva common utils network ratelimit Function save state
flowchart TB
n1([開始])
n2([結束])
n3['Force write state to disk immediately.&&...]
n4[self._write_state(force=True)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Force write state to disk immediately.&&...]
n4[self._write_state(force=True)]
n1 --> n3
n3 --> n4
n4 --> n2
59. aiva common utils network ratelimit Function should send
flowchart TB
n1([開始])
n2([結束])
n3['\n Check if requests to host are curr...]
n4[now = time.monotonic()]
n5[until = self._cooldown_until...]
n6[return not (until is not None and now...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Check if requests to host are curr...]
n4[now = time.monotonic()]
n5[until = self._cooldown_until...]
n6[return not (until is not None and now...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
60. aiva common utils network ratelimit Function take
flowchart TB
n1([開始])
n2([結束])
n3['Try to consume n tokens. Returns True if suc...]
n4[with self.lock]
n5[now = time.monotonic()]
n6[delta = now - self.updated]
n7[self.updated = now]
n8[self.tokens = min(self.capacity, s...]
n9{if self.tokens >= n}
n10[self.tokens -= n]
n11[return True]
n12[]
n13[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Try to consume n tokens. Returns True if suc...]
n4[with self.lock]
n5[now = time.monotonic()]
n6[delta = now - self.updated]
n7[self.updated = now]
n8[self.tokens = min(self.capacity, s...]
n9{if self.tokens &gt;= n}
n10[self.tokens -= n]
n11[return True]
n12[]
n13[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
61. aiva common utils network ratelimit Function update from response
flowchart TB
n1([開始])
n2([結束])
n3['\n Adjust global and per-host rates b...]
n4[self._touch_host(host)]
n5[global_penalty = 1.0]
n6[host_penalty = 1.0]
n7[base_penalty = 1.0]
n8[global_boost = 1.0]
n9[host_boost = 1.0]
n10[base_boost = 1.0]
n11[ra_until = None]
n12[try]
n13{if headers and any((k.lower() ...}
n14[ra_val = next((headers[k] for...]
n15{if ra_val is not None}
n16[ra_val = str(ra_val).strip()]
n17{if re.fullmatch('\\d+', ra_va...}
n18[ra_until = time.monotonic() + f...]
n19[try]
n20[dt = parsedate_to_datetim...]
n21[ra_until = time.monotonic() + m...]
n22[]
n23[except (ValueError,...]
n24[self._log.debug('Failed to parse HTTP-dat...]
n25[ra_until = None]
n26[]
n27[]
n28[]
n29[]
n30[except (KeyError, A...]
n31[self._log.debug('Failed to process Retry-...]
n32[ra_until = None]
n33{if ra_until is not None}
n34[prev = self._cooldown_until...]
n35[self._cooldown_until[host] = max(prev or 0.0,...]
n36[with contextli...]
n37[self._log.info('ratelimiter.cooldown_begi...]
n38[base_penalty *= 1.5]
n39[host_penalty *= 2.0]
n40[]
n41{if status_code is not None}
n42{if status_code == 429}
n43[global_penalty = min(global_penalty, ...]
n44[host_penalty = min(host_penalty, 0....]
n45[base_penalty = min(base_penalty, 0....]
n46{if status_code in {503, 504}}
n47[global_penalty = min(global_penalty, ...]
n48[host_penalty = min(host_penalty, 0....]
n49[base_penalty = min(base_penalty, 0....]
n50{if 500 <= status_code < 600}
n51[global_penalty = min(global_penalty, ...]
n52[host_penalty = min(host_penalty, 0....]
n53[base_penalty = min(base_penalty, 0....]
n54{if 200 <= status_code < 300}
n55[global_boost = max(global_boost, 1....]
n56[host_boost = max(host_boost, 1.08...]
n57[base_boost = max(base_boost, 1.02...]
n58[]
n59[]
n60[]
n61[]
n62[]
n63{if latency is not None}
n64{if latency > 5.0}
n65[global_penalty = min(global_penalty, ...]
n66[host_penalty = min(host_penalty, 0....]
n67[base_penalty = min(base_penalty, 0....]
n68{if latency > 2.5}
n69[global_penalty = min(global_penalty, ...]
n70[host_penalty = min(host_penalty, 0....]
n71[base_penalty = min(base_penalty, 0....]
n72{if latency < 0.3}
n73[global_boost = max(global_boost, 1....]
n74[host_boost = max(host_boost, 1.1)]
n75[base_boost = max(base_boost, 1.04...]
n76{if latency < 0.6}
n77[global_boost = max(global_boost, 1....]
n78[host_boost = max(host_boost, 1.05...]
n79[base_boost = max(base_boost, 1.02...]
n80[]
n81[]
n82[]
n83[]
n84[]
n85{if global_penalty < 1.0 or hos...}
n86{if global_penalty < 1.0}
n87[self._scale_global(global_penalty)]
n88[]
n89{if base_penalty < 1.0}
n90[self._scale_per_host_base(base_penalty)]
n91[]
n92{if host_penalty < 1.0}
n93[self._scale_host(host, host_penalty)]
n94[]
n95[return]
n96[]
n97{if global_boost > 1.0}
n98[self._scale_global(global_boost)]
n99[]
n100{if base_boost > 1.0}
n101[self._scale_per_host_base(base_boost)]
n102[]
n103{if host_boost > 1.0}
n104[self._scale_host(host, host_boost)]
n105[]
n106[try]
n107{if status_code and 200 <= int(...}
n108[until = self._cooldown_until...]
n109{if until}
n110[now = time.monotonic()]
n111{if now + max(0.0, latency) * 2...}
n112[self._cooldown_until.pop(host, None)]
n113[self._log.info('ratelimiter.cooldown_end ...]
n114[]
n115[]
n116[]
n117[]
n118[except (KeyError, V...]
n119[self._log.debug('Error processing respons...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n12 --> n30
n13 -->|Yes| n14
n13 -->|No| n28
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n27
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n26
n19 --> n20
n19 --> n23
n20 --> n21
n21 --> n22
n22 --> n26
n23 --> n24
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n33
n30 --> n31
n31 --> n32
n32 --> n29
n33 -->|Yes| n34
n33 -->|No| n40
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 -->|Yes| n42
n41 -->|No| n62
n42 -->|Yes| n43
n42 -->|No| n46
n43 --> n44
n44 --> n45
n45 --> n61
n46 -->|Yes| n47
n46 -->|No| n50
n47 --> n48
n48 --> n49
n49 --> n60
n50 -->|Yes| n51
n50 -->|No| n54
n51 --> n52
n52 --> n53
n53 --> n59
n54 -->|Yes| n55
n54 -->|No| n58
n55 --> n56
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 -->|Yes| n64
n63 -->|No| n84
n64 -->|Yes| n65
n64 -->|No| n68
n65 --> n66
n66 --> n67
n67 --> n83
n68 -->|Yes| n69
n68 -->|No| n72
n69 --> n70
n70 --> n71
n71 --> n82
n72 -->|Yes| n73
n72 -->|No| n76
n73 --> n74
n74 --> n75
n75 --> n81
n76 -->|Yes| n77
n76 -->|No| n80
n77 --> n78
n78 --> n79
n79 --> n80
n80 --> n81
n81 --> n82
n82 --> n83
n83 --> n84
n84 --> n85
n85 -->|Yes| n86
n85 -->|No| n96
n86 -->|Yes| n87
n86 -->|No| n88
n87 --> n88
n88 --> n89
n89 -->|Yes| n90
n89 -->|No| n91
n90 --> n91
n91 --> n92
n92 -->|Yes| n93
n92 -->|No| n94
n93 --> n94
n94 --> n95
n95 --> n96
n96 --> n97
n97 -->|Yes| n98
n97 -->|No| n99
n98 --> n99
n99 --> n100
n100 -->|Yes| n101
n100 -->|No| n102
n101 --> n102
n102 --> n103
n103 -->|Yes| n104
n103 -->|No| n105
n104 --> n105
n105 --> n106
n106 --> n107
n106 --> n118
n107 -->|Yes| n108
n107 -->|No| n116
n108 --> n109
n109 -->|Yes| n110
n109 -->|No| n115
n110 --> n111
n111 -->|Yes| n112
n111 -->|No| n114
n112 --> n113
n113 --> n114
n114 --> n115
n115 --> n116
n116 --> n117
n117 --> n2
n118 --> n119
n119 --> n117
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Adjust global and per-host rates b...]
n4[self._touch_host(host)]
n5[global_penalty = 1.0]
n6[host_penalty = 1.0]
n7[base_penalty = 1.0]
n8[global_boost = 1.0]
n9[host_boost = 1.0]
n10[base_boost = 1.0]
n11[ra_until = None]
n12[try]
n13{if headers and any((k.lower() ...}
n14[ra_val = next((headers[k] for...]
n15{if ra_val is not None}
n16[ra_val = str(ra_val).strip()]
n17{if re.fullmatch(&#39;\\d+&#39;, ra_va...}
n18[ra_until = time.monotonic() + f...]
n19[try]
n20[dt = parsedate_to_datetim...]
n21[ra_until = time.monotonic() + m...]
n22[]
n23[except (ValueError,...]
n24[self._log.debug(&#39;Failed to parse HTTP-dat...]
n25[ra_until = None]
n26[]
n27[]
n28[]
n29[]
n30[except (KeyError, A...]
n31[self._log.debug(&#39;Failed to process Retry-...]
n32[ra_until = None]
n33{if ra_until is not None}
n34[prev = self._cooldown_until...]
n35[self._cooldown_until[host] = max(prev or 0.0,...]
n36[with contextli...]
n37[self._log.info(&#39;ratelimiter.cooldown_begi...]
n38[base_penalty *= 1.5]
n39[host_penalty *= 2.0]
n40[]
n41{if status_code is not None}
n42{if status_code == 429}
n43[global_penalty = min(global_penalty, ...]
n44[host_penalty = min(host_penalty, 0....]
n45[base_penalty = min(base_penalty, 0....]
n46{if status_code in {503, 504}}
n47[global_penalty = min(global_penalty, ...]
n48[host_penalty = min(host_penalty, 0....]
n49[base_penalty = min(base_penalty, 0....]
n50{if 500 &lt;= status_code &lt; 600}
n51[global_penalty = min(global_penalty, ...]
n52[host_penalty = min(host_penalty, 0....]
n53[base_penalty = min(base_penalty, 0....]
n54{if 200 &lt;= status_code &lt; 300}
n55[global_boost = max(global_boost, 1....]
n56[host_boost = max(host_boost, 1.08...]
n57[base_boost = max(base_boost, 1.02...]
n58[]
n59[]
n60[]
n61[]
n62[]
n63{if latency is not None}
n64{if latency &gt; 5.0}
n65[global_penalty = min(global_penalty, ...]
n66[host_penalty = min(host_penalty, 0....]
n67[base_penalty = min(base_penalty, 0....]
n68{if latency &gt; 2.5}
n69[global_penalty = min(global_penalty, ...]
n70[host_penalty = min(host_penalty, 0....]
n71[base_penalty = min(base_penalty, 0....]
n72{if latency &lt; 0.3}
n73[global_boost = max(global_boost, 1....]
n74[host_boost = max(host_boost, 1.1)]
n75[base_boost = max(base_boost, 1.04...]
n76{if latency &lt; 0.6}
n77[global_boost = max(global_boost, 1....]
n78[host_boost = max(host_boost, 1.05...]
n79[base_boost = max(base_boost, 1.02...]
n80[]
n81[]
n82[]
n83[]
n84[]
n85{if global_penalty &lt; 1.0 or hos...}
n86{if global_penalty &lt; 1.0}
n87[self._scale_global(global_penalty)]
n88[]
n89{if base_penalty &lt; 1.0}
n90[self._scale_per_host_base(base_penalty)]
n91[]
n92{if host_penalty &lt; 1.0}
n93[self._scale_host(host, host_penalty)]
n94[]
n95[return]
n96[]
n97{if global_boost &gt; 1.0}
n98[self._scale_global(global_boost)]
n99[]
n100{if base_boost &gt; 1.0}
n101[self._scale_per_host_base(base_boost)]
n102[]
n103{if host_boost &gt; 1.0}
n104[self._scale_host(host, host_boost)]
n105[]
n106[try]
n107{if status_code and 200 &lt;= int(...}
n108[until = self._cooldown_until...]
n109{if until}
n110[now = time.monotonic()]
n111{if now + max(0.0, latency) * 2...}
n112[self._cooldown_until.pop(host, None)]
n113[self._log.info(&#39;ratelimiter.cooldown_end ...]
n114[]
n115[]
n116[]
n117[]
n118[except (KeyError, V...]
n119[self._log.debug(&#39;Error processing respons...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n12 --> n30
n13 -->|Yes| n14
n13 -->|No| n28
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n27
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n26
n19 --> n20
n19 --> n23
n20 --> n21
n21 --> n22
n22 --> n26
n23 --> n24
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n33
n30 --> n31
n31 --> n32
n32 --> n29
n33 -->|Yes| n34
n33 -->|No| n40
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 -->|Yes| n42
n41 -->|No| n62
n42 -->|Yes| n43
n42 -->|No| n46
n43 --> n44
n44 --> n45
n45 --> n61
n46 -->|Yes| n47
n46 -->|No| n50
n47 --> n48
n48 --> n49
n49 --> n60
n50 -->|Yes| n51
n50 -->|No| n54
n51 --> n52
n52 --> n53
n53 --> n59
n54 -->|Yes| n55
n54 -->|No| n58
n55 --> n56
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 -->|Yes| n64
n63 -->|No| n84
n64 -->|Yes| n65
n64 -->|No| n68
n65 --> n66
n66 --> n67
n67 --> n83
n68 -->|Yes| n69
n68 -->|No| n72
n69 --> n70
n70 --> n71
n71 --> n82
n72 -->|Yes| n73
n72 -->|No| n76
n73 --> n74
n74 --> n75
n75 --> n81
n76 -->|Yes| n77
n76 -->|No| n80
n77 --> n78
n78 --> n79
n79 --> n80
n80 --> n81
n81 --> n82
n82 --> n83
n83 --> n84
n84 --> n85
n85 -->|Yes| n86
n85 -->|No| n96
n86 -->|Yes| n87
n86 -->|No| n88
n87 --> n88
n88 --> n89
n89 -->|Yes| n90
n89 -->|No| n91
n90 --> n91
n91 --> n92
n92 -->|Yes| n93
n92 -->|No| n94
n93 --> n94
n94 --> n95
n95 --> n96
n96 --> n97
n97 -->|Yes| n98
n97 -->|No| n99
n98 --> n99
n99 --> n100
n100 -->|Yes| n101
n100 -->|No| n102
n101 --> n102
n102 --> n103
n103 -->|Yes| n104
n103 -->|No| n105
n104 --> n105
n105 --> n106
n106 --> n107
n106 --> n118
n107 -->|Yes| n108
n107 -->|No| n116
n108 --> n109
n109 -->|Yes| n110
n109 -->|No| n115
n110 --> n111
n111 -->|Yes| n112
n111 -->|No| n114
n112 --> n113
n113 --> n114
n114 --> n115
n115 --> n116
n116 --> n117
n117 --> n2
n118 --> n119
n119 --> n117
62. core aiva core ai commander Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 AI 指揮官\n\n Args:\n cod...]
n4[logger.info('🎖️ Initializing AI Commander...]
n5[self.data_directory = data_directory or Pa...]
n6[self.data_directory.mkdir(parents=True, exist_ok=T...]
n7[logger.info(' Loading BioNeuronRAGAgent....]
n8[self.bio_neuron_agent = BioNeuronRAGAgent(co...]
n9[logger.info(' Loading RAG Engine...&...]
n10[vector_store = VectorStore(backend=...]
n11[knowledge_base = KnowledgeBase(vector...]
n12[self.rag_engine = RAGEngine(knowledge_...]
n13[logger.info(' Loading Training System......]
n14[self.experience_manager = ExperienceManager(st...]
n15[self.model_trainer = ModelTrainer(model_c...]
n16[from aiva_core.training.scenario_manager import Sc...]
n17[scenario_manager = ScenarioManager()]
n18[from aiva_core.execution.plan_executor import Plan...]
n19[from aiva_core.messaging.message_broker import Mes...]
n20[message_broker = MessageBroker()]
n21[plan_executor = PlanExecutor(message...]
n22[self.training_orchestrator = TrainingOrchestrator...]
n23[logger.info(' Loading Multi-Language Coo...]
n24[self.multilang_coordinator = MultiLanguageAICoord...]
n25[self.command_history: list[dict[str, Any]]...]
n26[self.active_tasks: dict[str, dict[str, Any]...]
n27[self.component_status: dict[str, bool] = {co...]
n28[logger.info('✅ AI Commander initialized s...]
n29[logger.info(f' - BioNeuronRAGAgent: ...]
n30[logger.info(f' - RAG Engine: {self...]
n31[logger.info(f' - Training System: {...]
n32[logger.info(f' - Multi-Language Coordin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 AI 指揮官\n\n Args:\n cod...]
n4[logger.info(&#39;🎖️ Initializing AI Commander...]
n5[self.data_directory = data_directory or Pa...]
n6[self.data_directory.mkdir(parents=True, exist_ok=T...]
n7[logger.info(&#39; Loading BioNeuronRAGAgent....]
n8[self.bio_neuron_agent = BioNeuronRAGAgent(co...]
n9[logger.info(&#39; Loading RAG Engine...&...]
n10[vector_store = VectorStore(backend=...]
n11[knowledge_base = KnowledgeBase(vector...]
n12[self.rag_engine = RAGEngine(knowledge_...]
n13[logger.info(&#39; Loading Training System......]
n14[self.experience_manager = ExperienceManager(st...]
n15[self.model_trainer = ModelTrainer(model_c...]
n16[from aiva_core.training.scenario_manager import Sc...]
n17[scenario_manager = ScenarioManager()]
n18[from aiva_core.execution.plan_executor import Plan...]
n19[from aiva_core.messaging.message_broker import Mes...]
n20[message_broker = MessageBroker()]
n21[plan_executor = PlanExecutor(message...]
n22[self.training_orchestrator = TrainingOrchestrator...]
n23[logger.info(&#39; Loading Multi-Language Coo...]
n24[self.multilang_coordinator = MultiLanguageAICoord...]
n25[self.command_history: list[dict[str, Any]]...]
n26[self.active_tasks: dict[str, dict[str, Any]&#...]
n27[self.component_status: dict[str, bool] = {co...]
n28[logger.info(&#39;✅ AI Commander initialized s...]
n29[logger.info(f&#39; - BioNeuronRAGAgent: ...]
n30[logger.info(f&#39; - RAG Engine: {self...]
n31[logger.info(f&#39; - Training System: {...]
n32[logger.info(f&#39; - Multi-Language Coordin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n2
63. core aiva core ai commander Function get status
flowchart TB
n1([開始])
n2([結束])
n3['獲取 AI 指揮官狀態\n\n Returns:\n ...]
n4[return {'component_status': ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取 AI 指揮官狀態\n\n Returns:\n ...]
n4[return {&#39;component_status&#39;: ...]
n1 --> n3
n3 --> n4
n4 --> n2
64. core aiva core ai commander Function save state
flowchart TB
n1([開始])
n2([結束])
n3['保存 AI 指揮官狀態']
n4[logger.info('💾 Saving AI Commander state....]
n5[self.rag_engine.save_knowledge()]
n6[self.experience_manager.export_to_jsonl(self.data_...]
n7[self.training_orchestrator.save_session()]
n8[logger.info('✅ AI Commander state saved&a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存 AI 指揮官狀態&#39;]
n4[logger.info(&#39;💾 Saving AI Commander state....]
n5[self.rag_engine.save_knowledge()]
n6[self.experience_manager.export_to_jsonl(self.data_...]
n7[self.training_orchestrator.save_session()]
n8[logger.info(&#39;✅ AI Commander state saved&a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
65. core aiva core ai controller Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化統一 AI 控制器']
n4[logger.info('🧠 初始化 AIVA 統一 AI 控制器...&...]
n5[self.master_ai = BioNeuronRAGAgent(co...]
n6[self.ai_components = {'code_fixer&...]
n7[self.decision_history = []]
n8[logger.info('✅ 統一 AI 控制器初始化完成'...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化統一 AI 控制器&#39;]
n4[logger.info(&#39;🧠 初始化 AIVA 統一 AI 控制器...&...]
n5[self.master_ai = BioNeuronRAGAgent(co...]
n6[self.ai_components = {&#39;code_fixer&&#...]
n7[self.decision_history = []]
n8[logger.info(&#39;✅ 統一 AI 控制器初始化完成&#39...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
66. core aiva core ai controller Function analyze task complexity
flowchart TB
n1([開始])
n2([結束])
n3['分析任務複雜度 - 決定處理策略']
n4[input_lower = user_input.lower()]
n5[analysis = {'can_handle_directl...]
n6[simple_patterns = ['讀取', &...]
n7{if any((pattern in input_lower...}
n8[analysis['can_handle_directly'...]
n9[analysis['complexity_score'...]
n10[]
n11[fix_patterns = ['修復', &...]
n12{if any((pattern in input_lower...}
n13[analysis['needs_code_fixing'&...]
n14[analysis['complexity_score'...]
n15[]
n16[detection_patterns = ['掃描', &...]
n17{if any((pattern in input_lower...}
n18[analysis['needs_specialized_detection&...]
n19[analysis['complexity_score'...]
n20[]
n21[analysis['confidence'] = ...]
n22[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析任務複雜度 - 決定處理策略&#39;]
n4[input_lower = user_input.lower()]
n5[analysis = {&#39;can_handle_directl...]
n6[simple_patterns = [&#39;讀取&#39;, &...]
n7{if any((pattern in input_lower...}
n8[analysis[&#39;can_handle_directly&#39...]
n9[analysis[&#39;complexity_score&#39;&#...]
n10[]
n11[fix_patterns = [&#39;修復&#39;, &&#...]
n12{if any((pattern in input_lower...}
n13[analysis[&#39;needs_code_fixing&#39;&...]
n14[analysis[&#39;complexity_score&#39;&#...]
n15[]
n16[detection_patterns = [&#39;掃描&#39;, &...]
n17{if any((pattern in input_lower...}
n18[analysis[&#39;needs_specialized_detection&...]
n19[analysis[&#39;complexity_score&#39;&#...]
n20[]
n21[analysis[&#39;confidence&#39;] = ...]
n22[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
67. core aiva core ai controller Function record unified decision
flowchart TB
n1([開始])
n2([結束])
n3['記錄統一決策歷史']
n4[decision_record = {'timestamp...]
n5[self.decision_history.append(decision_record)]
n6{if len(self.decision_history) ...}
n7[self.decision_history.pop(0)]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄統一決策歷史&#39;]
n4[decision_record = {&#39;timestamp&#3...]
n5[self.decision_history.append(decision_record)]
n6{if len(self.decision_history) ...}
n7[self.decision_history.pop(0)]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n2
68. core aiva core ai controller Function get control statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取統一控制統計']
n4{if not self.decision_history}
n5[return {'no_decisions': True...]
n6[]
n7[total_decisions = len(self.decision_hi...]
n8[unified_decisions = sum((1 for d in self...]
n9[conflict_free_decisions = sum((1 for d in self...]
n10[return {'total_decisions': t...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統一控制統計&#39;]
n4{if not self.decision_history}
n5[return {&#39;no_decisions&#39;: True...]
n6[]
n7[total_decisions = len(self.decision_hi...]
n8[unified_decisions = sum((1 for d in self...]
n9[conflict_free_decisions = sum((1 for d in self...]
n10[return {&#39;total_decisions&#39;: t...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
69. core aiva core ai engine backup bio neuron core Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 RAG 代理.\n\n Args:\n co...]
n4[logger.info('正在初始化 BioNeuronRAGAgent...&a...]
n5[self.tools: list[dict[str, str]] = [&...]
n6[self.tool_map: dict[str, dict[str, str]] ...]
n7[self.input_vector_size = 1024]
n8[self.decision_core = ScalableBioNet(self....]
n9[self.anti_hallucination = AntiHallucinationMod...]
n10[self.history: list[dict[str, Any]] = [...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 RAG 代理.\n\n Args:\n co...]
n4[logger.info(&#39;正在初始化 BioNeuronRAGAgent...&a...]
n5[self.tools: list[dict[str, str]] = [&...]
n6[self.tool_map: dict[str, dict[str, str]] ...]
n7[self.input_vector_size = 1024]
n8[self.decision_core = ScalableBioNet(self....]
n9[self.anti_hallucination = AntiHallucinationMod...]
n10[self.history: list[dict[str, Any]] = [...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
70. core aiva core ai engine backup bio neuron core Function create input vector
flowchart TB
n1([開始])
n2([結束])
n3['將任務和上下文轉換為輸入向量.\n\n Args:\n ...]
n4[task_hash = np.array([ord(c) for...]
n5[context_hash = np.array([ord(c) for...]
n6[task_vec = np.pad(task_hash, (0...]
n7[context_vec = np.pad(context_hash,...]
n8[combined_vec = np.concatenate([task...]
n9[return combined_vec / np.linalg.norm(...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將任務和上下文轉換為輸入向量.\n\n Args:\n ...]
n4[task_hash = np.array([ord(c) for...]
n5[context_hash = np.array([ord(c) for...]
n6[task_vec = np.pad(task_hash, (0...]
n7[context_vec = np.pad(context_hash,...]
n8[combined_vec = np.concatenate([task...]
n9[return combined_vec / np.linalg.norm(...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
71. core aiva core ai engine backup bio neuron core Function softmax
flowchart TB
n1([開始])
n2([結束])
n3['Softmax 激活函數.\n\n Args:\n ...]
n4[e_x = np.exp(x - np.max(x)...]
n5[return e_x / e_x.sum(axis=0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Softmax 激活函數.\n\n Args:\n ...]
n4[e_x = np.exp(x - np.max(x)...]
n5[return e_x / e_x.sum(axis=0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
72. core aiva core ai engine backup bio neuron core Function check confidence
flowchart TB
n1([開始])
n2([結束])
n3['檢查決策的信心度是否足夠.\n\n Args:\n ...]
n4[confidence = float(np.max(decisio...]
n5[is_confident = confidence >= thresh...]
n6{if not is_confident}
n7[logger.warning(f'[Anti-Hallucination&...]
n8[]
n9[return (is_confident, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查決策的信心度是否足夠.\n\n Args:\n ...]
n4[confidence = float(np.max(decisio...]
n5[is_confident = confidence &gt;= thresh...]
n6{if not is_confident}
n7[logger.warning(f&#39;[Anti-Hallucination&...]
n8[]
n9[return (is_confident, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
73. core aiva core ai engine backup bio neuron core Function forward
flowchart TB
n1([開始])
n2([結束])
n3['前向傳播,產生決策潛力.\n\n Args:\n x...]
n4[x = np.tanh(x @ self.fc1...]
n5[x = self.spiking1.forwar...]
n6[decision_potential = x @ self.fc2]
n7[return self._softmax(decision_potenti...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;前向傳播,產生決策潛力.\n\n Args:\n x...]
n4[x = np.tanh(x @ self.fc1...]
n5[x = self.spiking1.forwar...]
n6[decision_potential = x @ self.fc2]
n7[return self._softmax(decision_potenti...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
74. core aiva core ai engine backup bio neuron core Function get knowledge stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取知識庫統計信息']
n4[return {'total_chunks': 1279...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取知識庫統計信息&#39;]
n4[return {&#39;total_chunks&#39;: 1279...]
n1 --> n3
n3 --> n4
n4 --> n2
75. core aiva core ai engine backup bio neuron core Function invoke
flowchart TB
n1([開始])
n2([結束])
n3['\n 執行一個任務,包含完整的 RAG 流程.\n\n Ar...]
n4[logger.info(f'\n--- 開始新任務: {task...]
n5[logger.info('1. [檢索] 正在從知識庫中搜尋相關上...]
n6[context_str = '']
n7[logger.info('2. [增強] 正在結合任務與上下文.....]
n8[input_vector = self._create_input_v...]
n9[logger.info('3. [決策] BioNeuronAI ...]
n10[decision_potential = self.decision_core.f...]
n11[(is_confident, confidence) = self.anti_hallucinat...]
n12{if not is_confident}
n13[return {'status': &#...]
n14[]
n15[chosen_tool_index = int(np.argmax(decisi...]
n16[chosen_tool = self.tools[chosen_to...]
n17[tool_confidence = float(decision_poten...]
n18[logger.info(f"4. [執行] 選擇工具: &...]
n19[logger.info('5. [完成] 任務步驟執行完畢。&am...]
n20[response = {'status': &&...]
n21[self.history.append(response)]
n22[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 執行一個任務,包含完整的 RAG 流程.\n\n Ar...]
n4[logger.info(f&#39;\n--- 開始新任務: {task...]
n5[logger.info(&#39;1. [檢索] 正在從知識庫中搜尋相關上...]
n6[context_str = &#39;&#39;]
n7[logger.info(&#39;2. [增強] 正在結合任務與上下文.....]
n8[input_vector = self._create_input_v...]
n9[logger.info(&#39;3. [決策] BioNeuronAI ...]
n10[decision_potential = self.decision_core.f...]
n11[(is_confident, confidence) = self.anti_hallucinat...]
n12{if not is_confident}
n13[return {&#39;status&#39;: &#...]
n14[]
n15[chosen_tool_index = int(np.argmax(decisi...]
n16[chosen_tool = self.tools[chosen_to...]
n17[tool_confidence = float(decision_poten...]
n18[logger.info(f&quot;4. [執行] 選擇工具: &...]
n19[logger.info(&#39;5. [完成] 任務步驟執行完畢。&am...]
n20[response = {&#39;status&#39;: &&...]
n21[self.history.append(response)]
n22[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
76. core aiva core ai engine backup bio neuron core v2 Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 RAG 代理.\n\n Args:\n co...]
n4[from .knowledge_base import KnowledgeBase]
n5[from .tools import CodeAnalyzer, CodeReader, CodeW...]
n6[self.codebase_path = codebase_path]
n7[logger.info('BioNeuronRAGAgent 初始化&...]
n8[logger.info('程式碼庫: %s', codeb...]
n9[logger.info('[1/3] 正在索引程式碼庫...&am...]
n10[self.knowledge_base = KnowledgeBase(codeba...]
n11[self.knowledge_base.index_codebase()]
n12[logger.info('[2/3] 正在初始化工具系統...&a...]
n13[self.tool_instances = {'CodeReader&&...]
n14[self.tools = [{'name': &...]
n15[logger.info(' 已載入 %d 個工具', ...]
n16[logger.info('[3/3] 正在初始化生物神經決策核心....]
n17[self.decision_core = ScalableBioNet(input...]
n18[self.anti_hallucination = AntiHallucinationMod...]
n19[self.history: list[dict[str, Any]] = [...]
n20[logger.info('BioNeuronRAGAgent 初始化完成!&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 RAG 代理.\n\n Args:\n co...]
n4[from .knowledge_base import KnowledgeBase]
n5[from .tools import CodeAnalyzer, CodeReader, CodeW...]
n6[self.codebase_path = codebase_path]
n7[logger.info(&#39;BioNeuronRAGAgent 初始化&&#...]
n8[logger.info(&#39;程式碼庫: %s&#39;, codeb...]
n9[logger.info(&#39;[1/3] 正在索引程式碼庫...&am...]
n10[self.knowledge_base = KnowledgeBase(codeba...]
n11[self.knowledge_base.index_codebase()]
n12[logger.info(&#39;[2/3] 正在初始化工具系統...&a...]
n13[self.tool_instances = {&#39;CodeReader&&...]
n14[self.tools = [{&#39;name&#39;: &...]
n15[logger.info(&#39; 已載入 %d 個工具&#39;, ...]
n16[logger.info(&#39;[3/3] 正在初始化生物神經決策核心....]
n17[self.decision_core = ScalableBioNet(input...]
n18[self.anti_hallucination = AntiHallucinationMod...]
n19[self.history: list[dict[str, Any]] = [...]
n20[logger.info(&#39;BioNeuronRAGAgent 初始化完成!&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
77. core aiva core ai engine backup bio neuron core v2 Function check
flowchart TB
n1([開始])
n2([結束])
n3['檢查決策的信心度.\n\n Args:\n deci...]
n4[confidence = float(np.max(decisio...]
n5[passed = confidence >= self.c...]
n6[return (passed, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查決策的信心度.\n\n Args:\n deci...]
n4[confidence = float(np.max(decisio...]
n5[passed = confidence &gt;= self.c...]
n6[return (passed, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
78. core aiva core ai engine backup bio neuron core v2 Function forward
flowchart TB
n1([開始])
n2([結束])
n3['前向傳播.\n\n Args:\n x: 輸入向量\...]
n4[h1 = np.dot(x, self.fc1)]
n5[h1 = np.maximum(0, h1)]
n6[h2 = self.spiking_layer.f...]
n7[output = np.dot(h2, self.fc2)]
n8[return output]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;前向傳播.\n\n Args:\n x: 輸入向量\...]
n4[h1 = np.dot(x, self.fc1)]
n5[h1 = np.maximum(0, h1)]
n6[h2 = self.spiking_layer.f...]
n7[output = np.dot(h2, self.fc2)]
n8[return output]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
79. core aiva core ai engine backup bio neuron core v2 Function get history
flowchart TB
n1([開始])
n2([結束])
n3['獲取執行歷史.\n\n Returns:\n 執行歷...]
n4[return self.history]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取執行歷史.\n\n Returns:\n 執行歷...]
n4[return self.history]
n1 --> n3
n3 --> n4
n4 --> n2
80. core aiva core ai engine backup bio neuron core v2 Function get knowledge stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取知識庫統計.\n\n Returns:\n 知識...]
n4[return {'total_chunks': self...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取知識庫統計.\n\n Returns:\n 知識...]
n4[return {&#39;total_chunks&#39;: self...]
n1 --> n3
n3 --> n4
n4 --> n2
81. core aiva core ai engine backup bio neuron core v2 Function invoke
flowchart TB
n1([開始])
n2([結束])
n3['執行 RAG 增強的智能決策與工具執行.\n\n Args:\n ...]
n4[logger.info('[啟動] 收到新任務: %s&&...]
n5[logger.info('[資料] [步驟 1/5]...]
n6[retrieved_chunks = self.knowledge_base....]
n7[logger.info(' [V] 檢索到 %d 個相關程式碼...]
n8{for (i, chunk) in enumerate(retriev...}
n9[logger.info(' %d. %s - %s (分數: %s...]
n10[]
n11[context_str = '\n\n'.join(...]
n12[logger.info('[數值] [步驟 2/5]...]
n13[query_hash = sum((ord(c) for c in...]
n14[context_hash = sum((ord(c) for c in...]
n15[seed = query_hash + context...]
n16[np.random.seed(seed)]
n17[query_embedding = np.random.randn(512)...]
n18[logger.info(' 生成 512 維嵌入向量 (種子: %d&...]
n19[logger.info('[神經網路] [步驟 3/5...]
n20[decision_logits = self.decision_core.f...]
n21[logger.info(' 決策邏輯值範圍: [%.2f, %.2f&...]
n22[logger.info('[計算] [步驟 4/5]...]
n23[(_, confidence) = self.anti_hallucinat...]
n24[logger.info(' 信心度: %.2f%%',...]
n25[logger.info(' 已停用信心度檢查,所有決策都會執行&...]
n26[logger.info('[調整] [步驟 5/5]...]
n27[chosen_tool_index = int(np.argmax(decisi...]
n28[chosen_tool = self.tools[chosen_to...]
n29[chosen_tool_name = chosen_tool['name&...]
n30[tool_confidence = float(decision_logit...]
n31[logger.info(' 選擇工具: %s', ch...]
n32[logger.info(' 工具描述: %s', ch...]
n33[logger.info(' 選擇信心度: %.2f%%'...]
n34[tool_instance = self.tool_instances....]
n35{if tool_instance}
n36[logger.info(' 正在執行工具...')]
n37[tool_result = tool_instance.execut...]
n38[logger.info(' 工具執行完成: %s', ...]
n39[tool_result = {'status': &am...]
n40[logger.error('工具未實作: %s', cho...]
n41[]
n42[response = {'status': &&...]
n43[self.history.append(response)]
n44[logger.info('%s', ...]
n45[logger.info('[已] 任務完成!...]
n46[logger.info('%s', ...]
n47[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n39
n36 --> n37
n37 --> n38
n38 --> n41
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行 RAG 增強的智能決策與工具執行.\n\n Args:\n ...]
n4[logger.info(&#39;[啟動] 收到新任務: %s&&...]
n5[logger.info(&#39;[資料] [步驟 1/5]...]
n6[retrieved_chunks = self.knowledge_base....]
n7[logger.info(&#39; [V] 檢索到 %d 個相關程式碼...]
n8{for (i, chunk) in enumerate(retriev...}
n9[logger.info(&#39; %d. %s - %s (分數: %s...]
n10[]
n11[context_str = &#39;\n\n&#39;.join(...]
n12[logger.info(&#39;[數值] [步驟 2/5]...]
n13[query_hash = sum((ord(c) for c in...]
n14[context_hash = sum((ord(c) for c in...]
n15[seed = query_hash + context...]
n16[np.random.seed(seed)]
n17[query_embedding = np.random.randn(512)...]
n18[logger.info(&#39; 生成 512 維嵌入向量 (種子: %d&...]
n19[logger.info(&#39;[神經網路] [步驟 3/5&#...]
n20[decision_logits = self.decision_core.f...]
n21[logger.info(&#39; 決策邏輯值範圍: [%.2f, %.2f&...]
n22[logger.info(&#39;[計算] [步驟 4/5]...]
n23[(_, confidence) = self.anti_hallucinat...]
n24[logger.info(&#39; 信心度: %.2f%%&#39;,...]
n25[logger.info(&#39; 已停用信心度檢查,所有決策都會執行&...]
n26[logger.info(&#39;[調整] [步驟 5/5]...]
n27[chosen_tool_index = int(np.argmax(decisi...]
n28[chosen_tool = self.tools[chosen_to...]
n29[chosen_tool_name = chosen_tool[&#39;name&...]
n30[tool_confidence = float(decision_logit...]
n31[logger.info(&#39; 選擇工具: %s&#39;, ch...]
n32[logger.info(&#39; 工具描述: %s&#39;, ch...]
n33[logger.info(&#39; 選擇信心度: %.2f%%&#39...]
n34[tool_instance = self.tool_instances....]
n35{if tool_instance}
n36[logger.info(&#39; 正在執行工具...&#39;)]
n37[tool_result = tool_instance.execut...]
n38[logger.info(&#39; 工具執行完成: %s&#39;, ...]
n39[tool_result = {&#39;status&#39;: &am...]
n40[logger.error(&#39;工具未實作: %s&#39;, cho...]
n41[]
n42[response = {&#39;status&#39;: &&...]
n43[self.history.append(response)]
n44[logger.info(&#39;%s&#39;, &#3...]
n45[logger.info(&#39;[已] 任務完成!&#3...]
n46[logger.info(&#39;%s&#39;, &#3...]
n47[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n39
n36 --> n37
n37 --> n38
n38 --> n41
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n2
82. core aiva core ai engine backup knowledge base Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化知識庫.\n\n Args:\n codeba...]
n4[self.codebase_path = Path(codebase_path)]
n5[self.chunks: list[dict[str, Any]] = [...]
n6[self.index: dict[str, list[int]] = {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化知識庫.\n\n Args:\n codeba...]
n4[self.codebase_path = Path(codebase_path)]
n5[self.chunks: list[dict[str, Any]] = [...]
n6[self.index: dict[str, list[int]] = {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
83. core aiva core ai engine backup knowledge base Function add chunk
flowchart TB
n1([開始])
n2([結束])
n3['添加程式碼片段到知識庫.\n\n Args:\n f...]
n4[chunk_id = len(self.chunks)]
n5[chunk = {'id': chunk_id, &am...]
n6[self.chunks.append(chunk)]
n7[keywords = self._extract_keywor...]
n8{for keyword in keywords}
n9{if keyword not in self.index}
n10[self.index[keyword] = []]
n11[]
n12[self.index[keyword].append(chunk_id)]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n8
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加程式碼片段到知識庫.\n\n Args:\n f...]
n4[chunk_id = len(self.chunks)]
n5[chunk = {&#39;id&#39;: chunk_id, &am...]
n6[self.chunks.append(chunk)]
n7[keywords = self._extract_keywor...]
n8{for keyword in keywords}
n9{if keyword not in self.index}
n10[self.index[keyword] = []]
n11[]
n12[self.index[keyword].append(chunk_id)]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n8
n13 --> n2
84. core aiva core ai engine backup knowledge base Function extract keywords
flowchart TB
n1([開始])
n2([結束])
n3['從內容中提取關鍵字.\n\n Args:\n con...]
n4[keywords = set()]
n5[keywords.add(node_name.lower())]
n6[common_keywords = ['def', &am...]
n7{for keyword in common_keywords}
n8{if keyword in content.lower()}
n9[keywords.add(keyword)]
n10[]
n11[]
n12[return keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從內容中提取關鍵字.\n\n Args:\n con...]
n4[keywords = set()]
n5[keywords.add(node_name.lower())]
n6[common_keywords = [&#39;def&#39;, &am...]
n7{for keyword in common_keywords}
n8{if keyword in content.lower()}
n9[keywords.add(keyword)]
n10[]
n11[]
n12[return keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
85. core aiva core ai engine backup knowledge base Function index file
flowchart TB
n1([開始])
n2([結束])
n3['索引單個檔案.\n\n Args:\n file_p...]
n4[try]
n5[tree = ast.parse(content)]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.Functi...}
n8[chunk_content = ast.get_source_segme...]
n9{if chunk_content}
n10[self._add_chunk(file_path=str(file_path.relative_...]
n11[]
n12[]
n13[]
n14[]
n15[except SyntaxError]
n16[self._add_chunk(file_path=str(file_path.relative_...]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n15
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
n15 --> n16
n16 --> n14
flowchart TB
n1([開始])
n2([結束])
n3[&#39;索引單個檔案.\n\n Args:\n file_p...]
n4[try]
n5[tree = ast.parse(content)]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.Functi...}
n8[chunk_content = ast.get_source_segme...]
n9{if chunk_content}
n10[self._add_chunk(file_path=str(file_path.relative_...]
n11[]
n12[]
n13[]
n14[]
n15[except SyntaxError]
n16[self._add_chunk(file_path=str(file_path.relative_...]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n15
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
n15 --> n16
n16 --> n14
86. core aiva core ai engine backup knowledge base Function get chunk count
flowchart TB
n1([開始])
n2([結束])
n3['獲取程式碼片段總數.\n\n Returns:\n ...]
n4[return len(self.chunks)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取程式碼片段總數.\n\n Returns:\n ...]
n4[return len(self.chunks)]
n1 --> n3
n3 --> n4
n4 --> n2
87. core aiva core ai engine backup knowledge base Function get file content
flowchart TB
n1([開始])
n2([結束])
n3['獲取完整檔案內容.\n\n Args:\n file...]
n4[try]
n5[full_path = self.codebase_path /...]
n6[return full_path.read_text(encoding='...]
n7[]
n8[except Exception]
n9[logger.error(f'無法讀取檔案 {file_path...]
n10[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n7
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取完整檔案內容.\n\n Args:\n file...]
n4[try]
n5[full_path = self.codebase_path /...]
n6[return full_path.read_text(encoding=&#39;...]
n7[]
n8[except Exception]
n9[logger.error(f&#39;無法讀取檔案 {file_path...]
n10[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n7
88. core aiva core ai engine backup knowledge base Function index codebase
flowchart TB
n1([開始])
n2([結束])
n3['索引整個程式碼庫.']
n4[logger.info(f'正在索引程式碼庫: {self.codeba...]
n5[exclude_dirs = {'__pycache__'...]
n6{for py_file in self.codebase_pat...}
n7{if any((excluded in py_file.pa...}
n8[continue]
n9[]
n10[try]
n11[content = py_file.read_text(en...]
n12[self._index_file(py_file, content)]
n13[]
n14[except Exception]
n15[logger.warning(f' 跳過檔案 {py_file...]
n16[]
n17[logger.info(f'索引完成,共 {len(self.c...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n10 --> n14
n11 --> n12
n12 --> n13
n13 --> n6
n14 --> n15
n15 --> n13
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;索引整個程式碼庫.&#39;]
n4[logger.info(f&#39;正在索引程式碼庫: {self.codeba...]
n5[exclude_dirs = {&#39;__pycache__&#39...]
n6{for py_file in self.codebase_pat...}
n7{if any((excluded in py_file.pa...}
n8[continue]
n9[]
n10[try]
n11[content = py_file.read_text(en...]
n12[self._index_file(py_file, content)]
n13[]
n14[except Exception]
n15[logger.warning(f&#39; 跳過檔案 {py_file...]
n16[]
n17[logger.info(f&#39;索引完成,共 {len(self.c...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n10 --> n14
n11 --> n12
n12 --> n13
n13 --> n6
n14 --> n15
n15 --> n13
n16 --> n17
n17 --> n2
89. core aiva core ai engine backup knowledge base Function search
flowchart TB
n1([開始])
n2([結束])
n3['檢索相關的程式碼片段.\n\n Args:\n qu...]
n4[query_keywords = query.lower().split(...]
n5[scores: dict[int, int] = {}]
n6{for keyword in query_keywords}
n7{if keyword in self.index}
n8{for chunk_id in self.index[keyword]}
n9[scores[chunk_id] = scores.get(chunk_id,...]
n10[]
n11[]
n12[]
n13[sorted_chunks = sorted(scores.items(...]
n14[results = []]
n15{for (chunk_id, score) in sorted_chunks[:to...}
n16[chunk = self.chunks[chunk_id...]
n17[results.append({'path': ...]
n18[]
n19[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n6
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢索相關的程式碼片段.\n\n Args:\n qu...]
n4[query_keywords = query.lower().split(...]
n5[scores: dict[int, int] = {}]
n6{for keyword in query_keywords}
n7{if keyword in self.index}
n8{for chunk_id in self.index[keyword]}
n9[scores[chunk_id] = scores.get(chunk_id,...]
n10[]
n11[]
n12[]
n13[sorted_chunks = sorted(scores.items(...]
n14[results = []]
n15{for (chunk_id, score) in sorted_chunks[:to...}
n16[chunk = self.chunks[chunk_id...]
n17[results.append({&#39;path&#39;: ...]
n18[]
n19[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n6
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n2
90. core aiva core ai engine backup tools Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化漏洞檢測器.']
n4[super().__init__(name='Vulnerabil...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化漏洞檢測器.&#39;]
n4[super().__init__(name=&#39;Vulnerabil...]
n1 --> n3
n3 --> n4
n4 --> n2
91. core aiva core ai engine backup tools Function calculate complexity
flowchart TB
n1([開始])
n2([結束])
n3['計算循環複雜度.\n\n Args:\n tree:...]
n4[import ast]
n5[complexity = 1]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.If | a...}
n8[complexity += 1]
n9{if isinstance(node, ast.BoolOp)}
n10[complexity += len(node.values) - 1]
n11[]
n12[]
n13[]
n14[return complexity]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算循環複雜度.\n\n Args:\n tree:...]
n4[import ast]
n5[complexity = 1]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.If | a...}
n8[complexity += 1]
n9{if isinstance(node, ast.BoolOp)}
n10[complexity += len(node.values) - 1]
n11[]
n12[]
n13[]
n14[return complexity]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
92. core aiva core ai engine backup tools Function check docstrings
flowchart TB
n1([開始])
n2([結束])
n3['檢查是否有文檔字串.\n\n Args:\n tre...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7[docstring = ast.get_docstring(no...]
n8{if docstring}
n9[return True]
n10[]
n11[]
n12[]
n13[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查是否有文檔字串.\n\n Args:\n tre...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7[docstring = ast.get_docstring(no...]
n8{if docstring}
n9[return True]
n10[]
n11[]
n12[]
n13[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
93. core aiva core ai engine backup tools Function check type hints
flowchart TB
n1([開始])
n2([結束])
n3['檢查是否使用類型提示.\n\n Args:\n tr...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7{if node.args.args}
n8{for arg in node.args.args}
n9{if arg.annotation is not None}
n10[return True]
n11[]
n12[]
n13[]
n14{if node.returns is not None}
n15[return True]
n16[]
n17[]
n18[]
n19[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n18
n6 -->|Yes| n7
n6 -->|No| n17
n7 -->|Yes| n8
n7 -->|No| n13
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n5
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查是否使用類型提示.\n\n Args:\n tr...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7{if node.args.args}
n8{for arg in node.args.args}
n9{if arg.annotation is not None}
n10[return True]
n11[]
n12[]
n13[]
n14{if node.returns is not None}
n15[return True]
n16[]
n17[]
n18[]
n19[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n18
n6 -->|Yes| n7
n6 -->|No| n17
n7 -->|Yes| n8
n7 -->|No| n13
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n5
n18 --> n19
n19 --> n2
94. core aiva core ai engine backup tools Function execute
flowchart TB
n1([開始])
n2([結束])
n3['執行漏洞檢測.\n\n Args:\n **kwar...]
n4[vuln_type = kwargs.get('vuln_typ...]
n5[target = kwargs.get('target',...]
n6{if not vuln_type}
n7[return {'status': &#...]
n8[]
n9{if not target}
n10[return {'status': &#...]
n11[]
n12[return {'status': &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行漏洞檢測.\n\n Args:\n **kwar...]
n4[vuln_type = kwargs.get(&#39;vuln_typ...]
n5[target = kwargs.get(&#39;target&#39;,...]
n6{if not vuln_type}
n7[return {&#39;status&#39;: &#...]
n8[]
n9{if not target}
n10[return {&#39;status&#39;: &#...]
n11[]
n12[return {&#39;status&#39;: &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
95. core aiva core ai engine bio neuron core Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 RAG 代理.\n\n Args:\n co...]
n4[logger.info('正在初始化 BioNeuronRAGAgent...&a...]
n5[self.codebase_path = codebase_path]
n6[self.enable_planner = enable_planner]
n7[self.enable_tracer = enable_tracer]
n8[self.enable_experience = enable_experience]
n9[self.tools: list[dict[str, str]] = [&...]
n10[self.tool_map: dict[str, dict[str, str]] ...]
n11[self.input_vector_size = 1024]
n12[self.decision_core = ScalableBioNet(self....]
n13[self.anti_hallucination = AntiHallucinationMod...]
n14[self.history: list[dict[str, Any]] = [...]
n15{if enable_planner}
n16[from ..planner.orchestrator import AttackOrchestra...]
n17[self.orchestrator = AttackOrchestrator()]
n18[logger.info('✓ Planner/Orchestrator enabl...]
n19[self.orchestrator = None]
n20[]
n21{if enable_tracer}
n22[from ..execution_tracer.execution_monitor import E...]
n23[from ..execution_tracer.task_executor import TaskE...]
n24[self.execution_monitor = ExecutionMonitor()]
n25[self.task_executor = TaskExecutor(self.ex...]
n26[logger.info('✓ Execution Tracer enabled&a...]
n27[self.execution_monitor = None]
n28[self.task_executor = None]
n29[]
n30{if enable_experience}
n31[try]
n32[from pathlib import Path]
n33[import sys]
n34[integration_path = Path(__file__).paren...]
n35{if str(integration_path) not i...}
n36[sys.path.insert(0, str(integration_path))]
n37[]
n38[from aiva_integration.reception.experience_reposit...]
n39[from ..analysis.ast_trace_comparator import ASTTra...]
n40[from .training.model_updater import ModelUpdater]
n41[self.experience_repo = ExperienceRepository...]
n42[self.comparator = ASTTraceComparator()]
n43[self.model_updater = ModelUpdater(self.de...]
n44[logger.info(f'✓ Experience learning enabl...]
n45[]
n46[except Exception]
n47[logger.warning(f'Failed to enable experie...]
n48[self.experience_repo = None]
n49[self.comparator = None]
n50[self.model_updater = None]
n51[self.experience_repo = None]
n52[self.comparator = None]
n53[self.model_updater = None]
n54[]
n55[logger.info('BioNeuronRAGAgent 初始化完成 ✓&am...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n19
n16 --> n17
n17 --> n18
n18 --> n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n27
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n29
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n51
n31 --> n32
n31 --> n46
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n37
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n54
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n45
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 RAG 代理.\n\n Args:\n co...]
n4[logger.info(&#39;正在初始化 BioNeuronRAGAgent...&a...]
n5[self.codebase_path = codebase_path]
n6[self.enable_planner = enable_planner]
n7[self.enable_tracer = enable_tracer]
n8[self.enable_experience = enable_experience]
n9[self.tools: list[dict[str, str]] = [&...]
n10[self.tool_map: dict[str, dict[str, str]] ...]
n11[self.input_vector_size = 1024]
n12[self.decision_core = ScalableBioNet(self....]
n13[self.anti_hallucination = AntiHallucinationMod...]
n14[self.history: list[dict[str, Any]] = [...]
n15{if enable_planner}
n16[from ..planner.orchestrator import AttackOrchestra...]
n17[self.orchestrator = AttackOrchestrator()]
n18[logger.info(&#39;✓ Planner/Orchestrator enabl...]
n19[self.orchestrator = None]
n20[]
n21{if enable_tracer}
n22[from ..execution_tracer.execution_monitor import E...]
n23[from ..execution_tracer.task_executor import TaskE...]
n24[self.execution_monitor = ExecutionMonitor()]
n25[self.task_executor = TaskExecutor(self.ex...]
n26[logger.info(&#39;✓ Execution Tracer enabled&a...]
n27[self.execution_monitor = None]
n28[self.task_executor = None]
n29[]
n30{if enable_experience}
n31[try]
n32[from pathlib import Path]
n33[import sys]
n34[integration_path = Path(__file__).paren...]
n35{if str(integration_path) not i...}
n36[sys.path.insert(0, str(integration_path))]
n37[]
n38[from aiva_integration.reception.experience_reposit...]
n39[from ..analysis.ast_trace_comparator import ASTTra...]
n40[from .training.model_updater import ModelUpdater]
n41[self.experience_repo = ExperienceRepository...]
n42[self.comparator = ASTTraceComparator()]
n43[self.model_updater = ModelUpdater(self.de...]
n44[logger.info(f&#39;✓ Experience learning enabl...]
n45[]
n46[except Exception]
n47[logger.warning(f&#39;Failed to enable experie...]
n48[self.experience_repo = None]
n49[self.comparator = None]
n50[self.model_updater = None]
n51[self.experience_repo = None]
n52[self.comparator = None]
n53[self.model_updater = None]
n54[]
n55[logger.info(&#39;BioNeuronRAGAgent 初始化完成 ✓&am...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n19
n16 --> n17
n17 --> n18
n18 --> n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n27
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n29
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n51
n31 --> n32
n31 --> n46
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n37
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n54
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n45
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 --> n2
96. core aiva core ai engine bio neuron core Function create input vector
flowchart TB
n1([開始])
n2([結束])
n3['將任務和上下文轉換為輸入向量.\n\n Args:\n ...]
n4[task_hash = np.array([ord(c) for...]
n5[context_hash = np.array([ord(c) for...]
n6[task_vec = np.pad(task_hash, (0...]
n7[context_vec = np.pad(context_hash,...]
n8[combined_vec = np.concatenate([task...]
n9[return combined_vec / np.linalg.norm(...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將任務和上下文轉換為輸入向量.\n\n Args:\n ...]
n4[task_hash = np.array([ord(c) for...]
n5[context_hash = np.array([ord(c) for...]
n6[task_vec = np.pad(task_hash, (0...]
n7[context_vec = np.pad(context_hash,...]
n8[combined_vec = np.concatenate([task...]
n9[return combined_vec / np.linalg.norm(...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
97. core aiva core ai engine bio neuron core Function softmax
flowchart TB
n1([開始])
n2([結束])
n3['Softmax 激活函數.\n\n Args:\n ...]
n4[e_x = np.exp(x - np.max(x)...]
n5[return e_x / e_x.sum(axis=0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Softmax 激活函數.\n\n Args:\n ...]
n4[e_x = np.exp(x - np.max(x)...]
n5[return e_x / e_x.sum(axis=0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
98. core aiva core ai engine bio neuron core Function check confidence
flowchart TB
n1([開始])
n2([結束])
n3['檢查決策的信心度是否足夠.\n\n Args:\n ...]
n4[confidence = float(np.max(decisio...]
n5[is_confident = confidence >= thresh...]
n6{if not is_confident}
n7[logger.warning(f'[Anti-Hallucination&...]
n8[]
n9[return (is_confident, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查決策的信心度是否足夠.\n\n Args:\n ...]
n4[confidence = float(np.max(decisio...]
n5[is_confident = confidence &gt;= thresh...]
n6{if not is_confident}
n7[logger.warning(f&#39;[Anti-Hallucination&...]
n8[]
n9[return (is_confident, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
99. core aiva core ai engine bio neuron core Function forward
flowchart TB
n1([開始])
n2([結束])
n3['前向傳播,產生決策潛力.\n\n Args:\n x...]
n4[x = np.tanh(x @ self.fc1...]
n5[x = self.spiking1.forwar...]
n6[decision_potential = x @ self.fc2]
n7[return self._softmax(decision_potenti...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;前向傳播,產生決策潛力.\n\n Args:\n x...]
n4[x = np.tanh(x @ self.fc1...]
n5[x = self.spiking1.forwar...]
n6[decision_potential = x @ self.fc2]
n7[return self._softmax(decision_potenti...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
100. core aiva core ai engine bio neuron core Function get knowledge stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取知識庫統計信息']
n4[stats = {'total_chunks': 127...]
n5{if self.experience_repo}
n6[try]
n7[exp_stats = self.experience_repo...]
n8[stats['total_experiences']...]
n9[stats['avg_experience_score'&...]
n10[]
n11[except Exception]
n12[logger.warning(f'Failed to get experience...]
n13[]
n14[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n6 --> n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取知識庫統計信息&#39;]
n4[stats = {&#39;total_chunks&#39;: 127...]
n5{if self.experience_repo}
n6[try]
n7[exp_stats = self.experience_repo...]
n8[stats[&#39;total_experiences&#39;]...]
n9[stats[&#39;avg_experience_score&#39;&...]
n10[]
n11[except Exception]
n12[logger.warning(f&#39;Failed to get experience...]
n13[]
n14[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n6 --> n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n2
101. core aiva core ai engine bio neuron core Function invoke
flowchart TB
n1([開始])
n2([結束])
n3['\n 執行一個任務,包含完整的 RAG 流程.\n\n Ar...]
n4[logger.info(f'\n--- 開始新任務: {task...]
n5[logger.info('1. [檢索] 正在從知識庫中搜尋相關上...]
n6[context_str = '']
n7[logger.info('2. [增強] 正在結合任務與上下文.....]
n8[input_vector = self._create_input_v...]
n9[logger.info('3. [決策] BioNeuronAI ...]
n10[decision_potential = self.decision_core.f...]
n11[(is_confident, confidence) = self.anti_hallucinat...]
n12{if not is_confident}
n13[return {'status': &#...]
n14[]
n15[chosen_tool_index = int(np.argmax(decisi...]
n16[chosen_tool = self.tools[chosen_to...]
n17[tool_confidence = float(decision_poten...]
n18[logger.info(f"4. [執行] 選擇工具: &...]
n19[logger.info('5. [完成] 任務步驟執行完畢。&am...]
n20[response = {'status': &&...]
n21[self.history.append(response)]
n22[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 執行一個任務,包含完整的 RAG 流程.\n\n Ar...]
n4[logger.info(f&#39;\n--- 開始新任務: {task...]
n5[logger.info(&#39;1. [檢索] 正在從知識庫中搜尋相關上...]
n6[context_str = &#39;&#39;]
n7[logger.info(&#39;2. [增強] 正在結合任務與上下文.....]
n8[input_vector = self._create_input_v...]
n9[logger.info(&#39;3. [決策] BioNeuronAI ...]
n10[decision_potential = self.decision_core.f...]
n11[(is_confident, confidence) = self.anti_hallucinat...]
n12{if not is_confident}
n13[return {&#39;status&#39;: &#...]
n14[]
n15[chosen_tool_index = int(np.argmax(decisi...]
n16[chosen_tool = self.tools[chosen_to...]
n17[tool_confidence = float(decision_poten...]
n18[logger.info(f&quot;4. [執行] 選擇工具: &...]
n19[logger.info(&#39;5. [完成] 任務步驟執行完畢。&am...]
n20[response = {&#39;status&#39;: &&...]
n21[self.history.append(response)]
n22[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
102. core aiva core ai engine bio neuron core Function train from experiences
flowchart TB
n1([開始])
n2([結束])
n3['從經驗庫訓練模型(新增方法)\n\n Args:\n ...]
n4{if not self.model_updater}
n5[return {'status': &#...]
n6[]
n7[logger.info('開始從經驗庫訓練模型...')]
n8[try]
n9[result = self.model_updater.u...]
n10[return result]
n11[]
n12[except Exception]
n13[logger.error(f'Training failed: {e...]
n14[return {'status': &#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n8 --> n12
n9 --> n10
n10 --> n11
n11 --> n2
n12 --> n13
n13 --> n14
n14 --> n11
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從經驗庫訓練模型(新增方法)\n\n Args:\n ...]
n4{if not self.model_updater}
n5[return {&#39;status&#39;: &#...]
n6[]
n7[logger.info(&#39;開始從經驗庫訓練模型...&#39;)]
n8[try]
n9[result = self.model_updater.u...]
n10[return result]
n11[]
n12[except Exception]
n13[logger.error(f&#39;Training failed: {e&#...]
n14[return {&#39;status&#39;: &#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n8 --> n12
n9 --> n10
n10 --> n11
n11 --> n2
n12 --> n13
n13 --> n14
n14 --> n11
103. core aiva core ai engine bio neuron core v2 Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 RAG 代理.\n\n Args:\n co...]
n4[from .knowledge_base import KnowledgeBase]
n5[from .tools import CodeAnalyzer, CodeReader, CodeW...]
n6[self.codebase_path = codebase_path]
n7[logger.info('BioNeuronRAGAgent 初始化&...]
n8[logger.info('程式碼庫: %s', codeb...]
n9[logger.info('[1/3] 正在索引程式碼庫...&am...]
n10[self.knowledge_base = KnowledgeBase(codeba...]
n11[self.knowledge_base.index_codebase()]
n12[logger.info('[2/3] 正在初始化工具系統...&a...]
n13[self.tool_instances = {'CodeReader&&...]
n14[self.tools = [{'name': &...]
n15[logger.info(' 已載入 %d 個工具', ...]
n16[logger.info('[3/3] 正在初始化生物神經決策核心....]
n17[self.decision_core = ScalableBioNet(input...]
n18[self.anti_hallucination = AntiHallucinationMod...]
n19[self.history: list[dict[str, Any]] = [...]
n20[logger.info('BioNeuronRAGAgent 初始化完成!&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 RAG 代理.\n\n Args:\n co...]
n4[from .knowledge_base import KnowledgeBase]
n5[from .tools import CodeAnalyzer, CodeReader, CodeW...]
n6[self.codebase_path = codebase_path]
n7[logger.info(&#39;BioNeuronRAGAgent 初始化&&#...]
n8[logger.info(&#39;程式碼庫: %s&#39;, codeb...]
n9[logger.info(&#39;[1/3] 正在索引程式碼庫...&am...]
n10[self.knowledge_base = KnowledgeBase(codeba...]
n11[self.knowledge_base.index_codebase()]
n12[logger.info(&#39;[2/3] 正在初始化工具系統...&a...]
n13[self.tool_instances = {&#39;CodeReader&&...]
n14[self.tools = [{&#39;name&#39;: &...]
n15[logger.info(&#39; 已載入 %d 個工具&#39;, ...]
n16[logger.info(&#39;[3/3] 正在初始化生物神經決策核心....]
n17[self.decision_core = ScalableBioNet(input...]
n18[self.anti_hallucination = AntiHallucinationMod...]
n19[self.history: list[dict[str, Any]] = [...]
n20[logger.info(&#39;BioNeuronRAGAgent 初始化完成!&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
104. core aiva core ai engine bio neuron core v2 Function check
flowchart TB
n1([開始])
n2([結束])
n3['檢查決策的信心度.\n\n Args:\n deci...]
n4[confidence = float(np.max(decisio...]
n5[passed = confidence >= self.c...]
n6[return (passed, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查決策的信心度.\n\n Args:\n deci...]
n4[confidence = float(np.max(decisio...]
n5[passed = confidence &gt;= self.c...]
n6[return (passed, confidence)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
105. core aiva core ai engine bio neuron core v2 Function forward
flowchart TB
n1([開始])
n2([結束])
n3['前向傳播.\n\n Args:\n x: 輸入向量\...]
n4[h1 = np.dot(x, self.fc1)]
n5[h1 = np.maximum(0, h1)]
n6[h2 = self.spiking_layer.f...]
n7[output = np.dot(h2, self.fc2)]
n8[return output]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;前向傳播.\n\n Args:\n x: 輸入向量\...]
n4[h1 = np.dot(x, self.fc1)]
n5[h1 = np.maximum(0, h1)]
n6[h2 = self.spiking_layer.f...]
n7[output = np.dot(h2, self.fc2)]
n8[return output]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
106. core aiva core ai engine bio neuron core v2 Function get history
flowchart TB
n1([開始])
n2([結束])
n3['獲取執行歷史.\n\n Returns:\n 執行歷...]
n4[return self.history]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取執行歷史.\n\n Returns:\n 執行歷...]
n4[return self.history]
n1 --> n3
n3 --> n4
n4 --> n2
107. core aiva core ai engine bio neuron core v2 Function get knowledge stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取知識庫統計.\n\n Returns:\n 知識...]
n4[return {'total_chunks': self...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取知識庫統計.\n\n Returns:\n 知識...]
n4[return {&#39;total_chunks&#39;: self...]
n1 --> n3
n3 --> n4
n4 --> n2
108. core aiva core ai engine bio neuron core v2 Function invoke
flowchart TB
n1([開始])
n2([結束])
n3['執行 RAG 增強的智能決策與工具執行.\n\n Args:\n ...]
n4[logger.info('[啟動] 收到新任務: %s&&...]
n5[logger.info('[資料] [步驟 1/5]...]
n6[retrieved_chunks = self.knowledge_base....]
n7[logger.info(' [V] 檢索到 %d 個相關程式碼...]
n8{for (i, chunk) in enumerate(retriev...}
n9[logger.info(' %d. %s - %s (分數: %s...]
n10[]
n11[context_str = '\n\n'.join(...]
n12[logger.info('[數值] [步驟 2/5]...]
n13[query_hash = sum((ord(c) for c in...]
n14[context_hash = sum((ord(c) for c in...]
n15[seed = query_hash + context...]
n16[np.random.seed(seed)]
n17[query_embedding = np.random.randn(512)...]
n18[logger.info(' 生成 512 維嵌入向量 (種子: %d&...]
n19[logger.info('[神經網路] [步驟 3/5...]
n20[decision_logits = self.decision_core.f...]
n21[logger.info(' 決策邏輯值範圍: [%.2f, %.2f&...]
n22[logger.info('[計算] [步驟 4/5]...]
n23[(_, confidence) = self.anti_hallucinat...]
n24[logger.info(' 信心度: %.2f%%',...]
n25[logger.info(' 已停用信心度檢查,所有決策都會執行&...]
n26[logger.info('[調整] [步驟 5/5]...]
n27[chosen_tool_index = int(np.argmax(decisi...]
n28[chosen_tool = self.tools[chosen_to...]
n29[chosen_tool_name = chosen_tool['name&...]
n30[tool_confidence = float(decision_logit...]
n31[logger.info(' 選擇工具: %s', ch...]
n32[logger.info(' 工具描述: %s', ch...]
n33[logger.info(' 選擇信心度: %.2f%%'...]
n34[tool_instance = self.tool_instances....]
n35{if tool_instance}
n36[logger.info(' 正在執行工具...')]
n37[tool_result = tool_instance.execut...]
n38[logger.info(' 工具執行完成: %s', ...]
n39[tool_result = {'status': &am...]
n40[logger.error('工具未實作: %s', cho...]
n41[]
n42[response = {'status': &&...]
n43[self.history.append(response)]
n44[logger.info('%s', ...]
n45[logger.info('[已] 任務完成!...]
n46[logger.info('%s', ...]
n47[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n39
n36 --> n37
n37 --> n38
n38 --> n41
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行 RAG 增強的智能決策與工具執行.\n\n Args:\n ...]
n4[logger.info(&#39;[啟動] 收到新任務: %s&&...]
n5[logger.info(&#39;[資料] [步驟 1/5]...]
n6[retrieved_chunks = self.knowledge_base....]
n7[logger.info(&#39; [V] 檢索到 %d 個相關程式碼...]
n8{for (i, chunk) in enumerate(retriev...}
n9[logger.info(&#39; %d. %s - %s (分數: %s...]
n10[]
n11[context_str = &#39;\n\n&#39;.join(...]
n12[logger.info(&#39;[數值] [步驟 2/5]...]
n13[query_hash = sum((ord(c) for c in...]
n14[context_hash = sum((ord(c) for c in...]
n15[seed = query_hash + context...]
n16[np.random.seed(seed)]
n17[query_embedding = np.random.randn(512)...]
n18[logger.info(&#39; 生成 512 維嵌入向量 (種子: %d&...]
n19[logger.info(&#39;[神經網路] [步驟 3/5&#...]
n20[decision_logits = self.decision_core.f...]
n21[logger.info(&#39; 決策邏輯值範圍: [%.2f, %.2f&...]
n22[logger.info(&#39;[計算] [步驟 4/5]...]
n23[(_, confidence) = self.anti_hallucinat...]
n24[logger.info(&#39; 信心度: %.2f%%&#39;,...]
n25[logger.info(&#39; 已停用信心度檢查,所有決策都會執行&...]
n26[logger.info(&#39;[調整] [步驟 5/5]...]
n27[chosen_tool_index = int(np.argmax(decisi...]
n28[chosen_tool = self.tools[chosen_to...]
n29[chosen_tool_name = chosen_tool[&#39;name&...]
n30[tool_confidence = float(decision_logit...]
n31[logger.info(&#39; 選擇工具: %s&#39;, ch...]
n32[logger.info(&#39; 工具描述: %s&#39;, ch...]
n33[logger.info(&#39; 選擇信心度: %.2f%%&#39...]
n34[tool_instance = self.tool_instances....]
n35{if tool_instance}
n36[logger.info(&#39; 正在執行工具...&#39;)]
n37[tool_result = tool_instance.execut...]
n38[logger.info(&#39; 工具執行完成: %s&#39;, ...]
n39[tool_result = {&#39;status&#39;: &am...]
n40[logger.error(&#39;工具未實作: %s&#39;, cho...]
n41[]
n42[response = {&#39;status&#39;: &&...]
n43[self.history.append(response)]
n44[logger.info(&#39;%s&#39;, &#3...]
n45[logger.info(&#39;[已] 任務完成!&#3...]
n46[logger.info(&#39;%s&#39;, &#3...]
n47[return response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n39
n36 --> n37
n37 --> n38
n38 --> n41
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n2
109. core aiva core ai engine knowledge base Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化知識庫.\n\n Args:\n codeba...]
n4[self.codebase_path = Path(codebase_path)]
n5[self.chunks: list[dict[str, Any]] = [...]
n6[self.index: dict[str, list[int]] = {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化知識庫.\n\n Args:\n codeba...]
n4[self.codebase_path = Path(codebase_path)]
n5[self.chunks: list[dict[str, Any]] = [...]
n6[self.index: dict[str, list[int]] = {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
110. core aiva core ai engine knowledge base Function add chunk
flowchart TB
n1([開始])
n2([結束])
n3['添加程式碼片段到知識庫.\n\n Args:\n f...]
n4[chunk_id = len(self.chunks)]
n5[chunk = {'id': chunk_id, &am...]
n6[self.chunks.append(chunk)]
n7[keywords = self._extract_keywor...]
n8{for keyword in keywords}
n9{if keyword not in self.index}
n10[self.index[keyword] = []]
n11[]
n12[self.index[keyword].append(chunk_id)]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n8
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加程式碼片段到知識庫.\n\n Args:\n f...]
n4[chunk_id = len(self.chunks)]
n5[chunk = {&#39;id&#39;: chunk_id, &am...]
n6[self.chunks.append(chunk)]
n7[keywords = self._extract_keywor...]
n8{for keyword in keywords}
n9{if keyword not in self.index}
n10[self.index[keyword] = []]
n11[]
n12[self.index[keyword].append(chunk_id)]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n8
n13 --> n2
111. core aiva core ai engine knowledge base Function extract keywords
flowchart TB
n1([開始])
n2([結束])
n3['從內容中提取關鍵字.\n\n Args:\n con...]
n4[keywords = set()]
n5[keywords.add(node_name.lower())]
n6[common_keywords = ['def', &am...]
n7{for keyword in common_keywords}
n8{if keyword in content.lower()}
n9[keywords.add(keyword)]
n10[]
n11[]
n12[return keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從內容中提取關鍵字.\n\n Args:\n con...]
n4[keywords = set()]
n5[keywords.add(node_name.lower())]
n6[common_keywords = [&#39;def&#39;, &am...]
n7{for keyword in common_keywords}
n8{if keyword in content.lower()}
n9[keywords.add(keyword)]
n10[]
n11[]
n12[return keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
112. core aiva core ai engine knowledge base Function index file
flowchart TB
n1([開始])
n2([結束])
n3['索引單個檔案.\n\n Args:\n file_p...]
n4[try]
n5[tree = ast.parse(content)]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.Functi...}
n8[chunk_content = ast.get_source_segme...]
n9{if chunk_content}
n10[self._add_chunk(file_path=str(file_path.relative_...]
n11[]
n12[]
n13[]
n14[]
n15[except SyntaxError]
n16[self._add_chunk(file_path=str(file_path.relative_...]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n15
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
n15 --> n16
n16 --> n14
flowchart TB
n1([開始])
n2([結束])
n3[&#39;索引單個檔案.\n\n Args:\n file_p...]
n4[try]
n5[tree = ast.parse(content)]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.Functi...}
n8[chunk_content = ast.get_source_segme...]
n9{if chunk_content}
n10[self._add_chunk(file_path=str(file_path.relative_...]
n11[]
n12[]
n13[]
n14[]
n15[except SyntaxError]
n16[self._add_chunk(file_path=str(file_path.relative_...]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n15
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
n15 --> n16
n16 --> n14
113. core aiva core ai engine knowledge base Function get chunk count
flowchart TB
n1([開始])
n2([結束])
n3['獲取程式碼片段總數.\n\n Returns:\n ...]
n4[return len(self.chunks)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取程式碼片段總數.\n\n Returns:\n ...]
n4[return len(self.chunks)]
n1 --> n3
n3 --> n4
n4 --> n2
114. core aiva core ai engine knowledge base Function get file content
flowchart TB
n1([開始])
n2([結束])
n3['獲取完整檔案內容.\n\n Args:\n file...]
n4[try]
n5[full_path = self.codebase_path /...]
n6[return full_path.read_text(encoding='...]
n7[]
n8[except Exception]
n9[logger.error(f'無法讀取檔案 {file_path...]
n10[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n7
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取完整檔案內容.\n\n Args:\n file...]
n4[try]
n5[full_path = self.codebase_path /...]
n6[return full_path.read_text(encoding=&#39;...]
n7[]
n8[except Exception]
n9[logger.error(f&#39;無法讀取檔案 {file_path...]
n10[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n7
115. core aiva core ai engine knowledge base Function index codebase
flowchart TB
n1([開始])
n2([結束])
n3['索引整個程式碼庫.']
n4[logger.info(f'正在索引程式碼庫: {self.codeba...]
n5[exclude_dirs = {'__pycache__'...]
n6{for py_file in self.codebase_pat...}
n7{if any((excluded in py_file.pa...}
n8[continue]
n9[]
n10[try]
n11[content = py_file.read_text(en...]
n12[self._index_file(py_file, content)]
n13[]
n14[except Exception]
n15[logger.warning(f' 跳過檔案 {py_file...]
n16[]
n17[logger.info(f'索引完成,共 {len(self.c...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n10 --> n14
n11 --> n12
n12 --> n13
n13 --> n6
n14 --> n15
n15 --> n13
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;索引整個程式碼庫.&#39;]
n4[logger.info(f&#39;正在索引程式碼庫: {self.codeba...]
n5[exclude_dirs = {&#39;__pycache__&#39...]
n6{for py_file in self.codebase_pat...}
n7{if any((excluded in py_file.pa...}
n8[continue]
n9[]
n10[try]
n11[content = py_file.read_text(en...]
n12[self._index_file(py_file, content)]
n13[]
n14[except Exception]
n15[logger.warning(f&#39; 跳過檔案 {py_file...]
n16[]
n17[logger.info(f&#39;索引完成,共 {len(self.c...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n10 --> n14
n11 --> n12
n12 --> n13
n13 --> n6
n14 --> n15
n15 --> n13
n16 --> n17
n17 --> n2
116. core aiva core ai engine knowledge base Function search
flowchart TB
n1([開始])
n2([結束])
n3['檢索相關的程式碼片段.\n\n Args:\n qu...]
n4[query_keywords = query.lower().split(...]
n5[scores: dict[int, int] = {}]
n6{for keyword in query_keywords}
n7{if keyword in self.index}
n8{for chunk_id in self.index[keyword]}
n9[scores[chunk_id] = scores.get(chunk_id,...]
n10[]
n11[]
n12[]
n13[sorted_chunks = sorted(scores.items(...]
n14[results = []]
n15{for (chunk_id, score) in sorted_chunks[:to...}
n16[chunk = self.chunks[chunk_id...]
n17[results.append({'path': ...]
n18[]
n19[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n6
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢索相關的程式碼片段.\n\n Args:\n qu...]
n4[query_keywords = query.lower().split(...]
n5[scores: dict[int, int] = {}]
n6{for keyword in query_keywords}
n7{if keyword in self.index}
n8{for chunk_id in self.index[keyword]}
n9[scores[chunk_id] = scores.get(chunk_id,...]
n10[]
n11[]
n12[]
n13[sorted_chunks = sorted(scores.items(...]
n14[results = []]
n15{for (chunk_id, score) in sorted_chunks[:to...}
n16[chunk = self.chunks[chunk_id...]
n17[results.append({&#39;path&#39;: ...]
n18[]
n19[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n6
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n2
117. core aiva core ai engine tools Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化漏洞檢測器.']
n4[super().__init__(name='Vulnerabil...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化漏洞檢測器.&#39;]
n4[super().__init__(name=&#39;Vulnerabil...]
n1 --> n3
n3 --> n4
n4 --> n2
118. core aiva core ai engine tools Function calculate complexity
flowchart TB
n1([開始])
n2([結束])
n3['計算循環複雜度.\n\n Args:\n tree:...]
n4[import ast]
n5[complexity = 1]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.If | a...}
n8[complexity += 1]
n9{if isinstance(node, ast.BoolOp)}
n10[complexity += len(node.values) - 1]
n11[]
n12[]
n13[]
n14[return complexity]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算循環複雜度.\n\n Args:\n tree:...]
n4[import ast]
n5[complexity = 1]
n6{for node in ast.walk(tree)}
n7{if isinstance(node, ast.If | a...}
n8[complexity += 1]
n9{if isinstance(node, ast.BoolOp)}
n10[complexity += len(node.values) - 1]
n11[]
n12[]
n13[]
n14[return complexity]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
119. core aiva core ai engine tools Function check docstrings
flowchart TB
n1([開始])
n2([結束])
n3['檢查是否有文檔字串.\n\n Args:\n tre...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7[docstring = ast.get_docstring(no...]
n8{if docstring}
n9[return True]
n10[]
n11[]
n12[]
n13[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查是否有文檔字串.\n\n Args:\n tre...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7[docstring = ast.get_docstring(no...]
n8{if docstring}
n9[return True]
n10[]
n11[]
n12[]
n13[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
120. core aiva core ai engine tools Function check type hints
flowchart TB
n1([開始])
n2([結束])
n3['檢查是否使用類型提示.\n\n Args:\n tr...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7{if node.args.args}
n8{for arg in node.args.args}
n9{if arg.annotation is not None}
n10[return True]
n11[]
n12[]
n13[]
n14{if node.returns is not None}
n15[return True]
n16[]
n17[]
n18[]
n19[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n18
n6 -->|Yes| n7
n6 -->|No| n17
n7 -->|Yes| n8
n7 -->|No| n13
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n5
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查是否使用類型提示.\n\n Args:\n tr...]
n4[import ast]
n5{for node in ast.walk(tree)}
n6{if isinstance(node, ast.Functi...}
n7{if node.args.args}
n8{for arg in node.args.args}
n9{if arg.annotation is not None}
n10[return True]
n11[]
n12[]
n13[]
n14{if node.returns is not None}
n15[return True]
n16[]
n17[]
n18[]
n19[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n18
n6 -->|Yes| n7
n6 -->|No| n17
n7 -->|Yes| n8
n7 -->|No| n13
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n5
n18 --> n19
n19 --> n2
121. core aiva core ai engine tools Function execute
flowchart TB
n1([開始])
n2([結束])
n3['執行漏洞檢測.\n\n Args:\n **kwar...]
n4[vuln_type = kwargs.get('vuln_typ...]
n5[target = kwargs.get('target',...]
n6{if not vuln_type}
n7[return {'status': &#...]
n8[]
n9{if not target}
n10[return {'status': &#...]
n11[]
n12[return {'status': &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行漏洞檢測.\n\n Args:\n **kwar...]
n4[vuln_type = kwargs.get(&#39;vuln_typ...]
n5[target = kwargs.get(&#39;target&#39;,...]
n6{if not vuln_type}
n7[return {&#39;status&#39;: &#...]
n8[]
n9{if not target}
n10[return {&#39;status&#39;: &#...]
n11[]
n12[return {&#39;status&#39;: &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
122. core aiva core ai engine training data loader Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化數據加載器\n\n Args:\n exper...]
n4[self.repository = experience_repositor...]
n5[logger.info('ExperienceDataLoader initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化數據加載器\n\n Args:\n exper...]
n4[self.repository = experience_repositor...]
n5[logger.info(&#39;ExperienceDataLoader initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
123. core aiva core ai engine training data loader Function extract features
flowchart TB
n1([開始])
n2([結束])
n3['從經驗記錄提取特徵向量\n\n Args:\n ex...]
n4[features = []]
n5[ast_graph = experience.ast_graph]
n6[features.append(len(ast_graph.get(...]
n7[features.append(len(ast_graph.get(...]
n8[metrics = experience.metrics_d...]
n9[features.append(metrics.get('completi...]
n10[features.append(metrics.get('sequence...]
n11[features.append(metrics.get('success_...]
n12[features.append(1.0 - metrics.get('er...]
n13[attack_type_map = {'sqli': 0...]
n14[attack_type_idx = attack_type_map.get(...]
n15{for i in range(len(attack_...}
n16[features.append(1.0 if i == attack_type_idx else 0...]
n17[]
n18[target_size = 1024]
n19[current_size = len(features)]
n20{if current_size < target_size}
n21[features.extend([0.0] * (target_size - cu...]
n22[features = features[:target_siz...]
n23[]
n24[return np.array(features, dtype=np.fl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n15
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n23
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從經驗記錄提取特徵向量\n\n Args:\n ex...]
n4[features = []]
n5[ast_graph = experience.ast_graph]
n6[features.append(len(ast_graph.get(&#3...]
n7[features.append(len(ast_graph.get(&#3...]
n8[metrics = experience.metrics_d...]
n9[features.append(metrics.get(&#39;completi...]
n10[features.append(metrics.get(&#39;sequence...]
n11[features.append(metrics.get(&#39;success_...]
n12[features.append(1.0 - metrics.get(&#39;er...]
n13[attack_type_map = {&#39;sqli&#39;: 0...]
n14[attack_type_idx = attack_type_map.get(...]
n15{for i in range(len(attack_...}
n16[features.append(1.0 if i == attack_type_idx else 0...]
n17[]
n18[target_size = 1024]
n19[current_size = len(features)]
n20{if current_size &lt; target_size}
n21[features.extend([0.0] * (target_size - cu...]
n22[features = features[:target_siz...]
n23[]
n24[return np.array(features, dtype=np.fl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n15
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n23
n22 --> n23
n23 --> n24
n24 --> n2
124. core aiva core ai engine training data loader Function prepare training data
flowchart TB
n1([開始])
n2([結束])
n3['準備訓練數據\n\n Args:\n experie...]
n4[features = []]
n5[labels = []]
n6{for exp in experiences}
n7[feature_vector = self._extract_featur...]
n8[features.append(feature_vector)]
n9[labels.append(exp.overall_score)]
n10[]
n11[X = np.array(features)]
n12[y = np.array(labels)]
n13[return (X, y)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n6
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;準備訓練數據\n\n Args:\n experie...]
n4[features = []]
n5[labels = []]
n6{for exp in experiences}
n7[feature_vector = self._extract_featur...]
n8[features.append(feature_vector)]
n9[labels.append(exp.overall_score)]
n10[]
n11[X = np.array(features)]
n12[y = np.array(labels)]
n13[return (X, y)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n6
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
125. core aiva core ai engine training data loader Function create validation split
flowchart TB
n1([開始])
n2([結束])
n3['創建驗證集分割\n\n Args:\n X: 特徵矩...]
n4[n_samples = len(X)]
n5[n_val = int(n_samples * val_...]
n6[indices = np.random.permutatio...]
n7[val_indices = indices[:n_val]]
n8[train_indices = indices[n_val:]]
n9[(X_train, y_train) = (X[train_indices]...]
n10[(X_val, y_val) = (X[val_indices], y...]
n11[logger.info(f'Created train/val split: ...]
n12[return (X_train, y_train, X_val, y_va...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建驗證集分割\n\n Args:\n X: 特徵矩...]
n4[n_samples = len(X)]
n5[n_val = int(n_samples * val_...]
n6[indices = np.random.permutatio...]
n7[val_indices = indices[:n_val]]
n8[train_indices = indices[n_val:]]
n9[(X_train, y_train) = (X[train_indices]...]
n10[(X_val, y_val) = (X[val_indices], y&#...]
n11[logger.info(f&#39;Created train/val split: &#...]
n12[return (X_train, y_train, X_val, y_va...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
126. core aiva core ai engine training data loader Function load dataset samples
flowchart TB
n1([開始])
n2([結束])
n3['從特定資料集加載樣本\n\n Args:\n dat...]
n4[samples = self.repository.get_...]
n5{if not samples}
n6[logger.warning(f'No samples found in data...]
n7[return (np.array([]), np.array(...]
n8[]
n9[experiences = [exp_record for _, e...]
n10[(X, y) = self._prepare_traini...]
n11{if shuffle}
n12[indices = np.random.permutatio...]
n13[X = X[indices]]
n14[y = y[indices]]
n15[]
n16[logger.info(f'Loaded {len(X)...]
n17[return (X, y)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從特定資料集加載樣本\n\n Args:\n dat...]
n4[samples = self.repository.get_...]
n5{if not samples}
n6[logger.warning(f&#39;No samples found in data...]
n7[return (np.array([]), np.array(&#...]
n8[]
n9[experiences = [exp_record for _, e...]
n10[(X, y) = self._prepare_traini...]
n11{if shuffle}
n12[indices = np.random.permutatio...]
n13[X = X[indices]]
n14[y = y[indices]]
n15[]
n16[logger.info(f&#39;Loaded {len(X)...]
n17[return (X, y)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
127. core aiva core ai engine training data loader Function load training batch
flowchart TB
n1([開始])
n2([結束])
n3['加載訓練批次\n\n Args:\n attack_...]
n4[experiences = self.repository.quer...]
n5{if not experiences}
n6[logger.warning('No experiences found for ...]
n7[return (np.array([]), np.array(...]
n8[]
n9[(X, y) = self._prepare_traini...]
n10[logger.info(f'Loaded training batch: ...]
n11[return (X, y)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;加載訓練批次\n\n Args:\n attack_...]
n4[experiences = self.repository.quer...]
n5{if not experiences}
n6[logger.warning(&#39;No experiences found for ...]
n7[return (np.array([]), np.array(&#...]
n8[]
n9[(X, y) = self._prepare_traini...]
n10[logger.info(f&#39;Loaded training batch: ...]
n11[return (X, y)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
128. core aiva core ai engine training model updater Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化更新器\n\n Args:\n model: ...]
n4[self.model = model]
n5[self.repository = experience_repositor...]
n6[self.data_loader = ExperienceDataLoader...]
n7[self.model_save_path = Path(model_save_path...]
n8[self.model_save_path.mkdir(parents=True, exist_ok=...]
n9[logger.info(f'ModelUpdater initialized, s...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化更新器\n\n Args:\n model: ...]
n4[self.model = model]
n5[self.repository = experience_repositor...]
n6[self.data_loader = ExperienceDataLoader...]
n7[self.model_save_path = Path(model_save_path...]
n8[self.model_save_path.mkdir(parents=True, exist_ok=...]
n9[logger.info(f&#39;ModelUpdater initialized, s...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
129. core aiva core ai engine training model updater Function save model
flowchart TB
n1([開始])
n2([結束])
n3['保存模型\n\n Returns:\n 模型保存路徑...]
n4[from datetime import datetime]
n5[timestamp = datetime.now().strft...]
n6[filename = f'scalable_bionet_{t...]
n7[filepath = self.model_save_path...]
n8[model_state = {'fc1': self.m...]
n9[with open(file...]
n10[pickle.dump(model_state, f)]
n11[logger.info(f'Model saved to {filepa...]
n12[return filepath]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存模型\n\n Returns:\n 模型保存路徑...]
n4[from datetime import datetime]
n5[timestamp = datetime.now().strft...]
n6[filename = f&#39;scalable_bionet_{t...]
n7[filepath = self.model_save_path...]
n8[model_state = {&#39;fc1&#39;: self.m...]
n9[with open(file...]
n10[pickle.dump(model_state, f)]
n11[logger.info(f&#39;Model saved to {filepa...]
n12[return filepath]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
130. core aiva core ai engine training model updater Function load model
flowchart TB
n1([開始])
n2([結束])
n3['加載模型\n\n Args:\n model_pat...]
n4[with open(mode...]
n5[model_state = pickle.load(f)]
n6[self.model.fc1 = model_state['fc1&...]
n7[self.model.fc2 = model_state['fc2&...]
n8[self.model.spiking1.weights = model_state[...]
n9[logger.info(f'Model loaded from {mod...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;加載模型\n\n Args:\n model_pat...]
n4[with open(mode...]
n5[model_state = pickle.load(f)]
n6[self.model.fc1 = model_state[&#39;fc1&...]
n7[self.model.fc2 = model_state[&#39;fc2&...]
n8[self.model.spiking1.weights = model_state[&#3...]
n9[logger.info(f&#39;Model loaded from {mod...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
131. core aiva core ai engine training model updater Function schedule periodic update
flowchart TB
n1([開始])
n2([結束])
n3['排程定期更新 (TODO: 需要與排程系統整合)\n\n ...]
n4[logger.info(f'Scheduling periodic updates...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;排程定期更新 (TODO: 需要與排程系統整合)\n\n ...]
n4[logger.info(f&#39;Scheduling periodic updates...]
n1 --> n3
n3 --> n4
n4 --> n2
132. core aiva core ai engine training model updater Function update from dataset
flowchart TB
n1([開始])
n2([結束])
n3['從特定資料集更新模型\n\n Args:\n dat...]
n4[logger.info(f'Starting model update from ...]
n5[(X, y) = self.data_loader.loa...]
n6{if len(X) == 0}
n7[logger.warning(f'No samples in dataset ...]
n8[return {'status': &#...]
n9[]
n10[(X_train, y_train, X_val, y_val) = self.data_load...]
n11[trainer = ModelTrainer(self.mo...]
n12[training_results = trainer.train(X_trai...]
n13[model_path = self._save_model()]
n14[training_history = self.repository.save...]
n15[self.repository.update_training_history(training_i...]
n16[logger.info(f'Model update from dataset &...]
n17[return {'status': &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從特定資料集更新模型\n\n Args:\n dat...]
n4[logger.info(f&#39;Starting model update from ...]
n5[(X, y) = self.data_loader.loa...]
n6{if len(X) == 0}
n7[logger.warning(f&#39;No samples in dataset &#...]
n8[return {&#39;status&#39;: &#...]
n9[]
n10[(X_train, y_train, X_val, y_val) = self.data_load...]
n11[trainer = ModelTrainer(self.mo...]
n12[training_results = trainer.train(X_trai...]
n13[model_path = self._save_model()]
n14[training_history = self.repository.save...]
n15[self.repository.update_training_history(training_i...]
n16[logger.info(f&#39;Model update from dataset &...]
n17[return {&#39;status&#39;: &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
133. core aiva core ai engine training model updater Function update from recent experiences
flowchart TB
n1([開始])
n2([結束])
n3['從最近的經驗更新模型\n\n Args:\n min...]
n4[logger.info(f'Starting model update from ...]
n5[(X, y) = self.data_loader.loa...]
n6{if len(X) == 0}
n7[logger.warning('No training data availabl...]
n8[return {'status': &#...]
n9[]
n10[(X_train, y_train, X_val, y_val) = self.data_load...]
n11[trainer = ModelTrainer(self.mo...]
n12[training_results = trainer.train(X_trai...]
n13[model_path = self._save_model()]
n14[training_history = self.repository.save...]
n15[self.repository.update_training_history(training_i...]
n16[logger.info(f"Model update completed: loss=&...]
n17[return {'status': &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從最近的經驗更新模型\n\n Args:\n min...]
n4[logger.info(f&#39;Starting model update from ...]
n5[(X, y) = self.data_loader.loa...]
n6{if len(X) == 0}
n7[logger.warning(&#39;No training data availabl...]
n8[return {&#39;status&#39;: &#...]
n9[]
n10[(X_train, y_train, X_val, y_val) = self.data_load...]
n11[trainer = ModelTrainer(self.mo...]
n12[training_results = trainer.train(X_trai...]
n13[model_path = self._save_model()]
n14[training_history = self.repository.save...]
n15[self.repository.update_training_history(training_i...]
n16[logger.info(f&quot;Model update completed: loss=&...]
n17[return {&#39;status&#39;: &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
134. core aiva core ai engine training trainer Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化訓練器\n\n Args:\n model: ...]
n4[self.model = model]
n5[self.config = config or TrainingCo...]
n6[self.training_history: dict[str, list[float]&...]
n7[logger.info('ModelTrainer initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化訓練器\n\n Args:\n model: ...]
n4[self.model = model]
n5[self.config = config or TrainingCo...]
n6[self.training_history: dict[str, list[float]&...]
n7[logger.info(&#39;ModelTrainer initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
135. core aiva core ai engine training trainer Function backward batch
flowchart TB
n1([開始])
n2([結束])
n3['批次反向傳播 (簡化版)\n\n Args:\n ...]
n4[lr = self.config.learning...]
n5[error = predictions - y]
n6{for i in range(min(len(X),...}
n7{if i < len(error)}
n8[gradient = error[i] * X[i][:sel...]
n9[self.model.fc1 -= lr * np.outer(gradient, np.ones(...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;批次反向傳播 (簡化版)\n\n Args:\n ...]
n4[lr = self.config.learning...]
n5[error = predictions - y]
n6{for i in range(min(len(X),...}
n7{if i &lt; len(error)}
n8[gradient = error[i] * X[i][:sel...]
n9[self.model.fc1 -= lr * np.outer(gradient, np.ones(...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n2
136. core aiva core ai engine training trainer Function forward batch
flowchart TB
n1([開始])
n2([結束])
n3['批次前向傳播\n\n Args:\n X: 輸入批次...]
n4[predictions = []]
n5{for x in X}
n6[pred = self.model.forward(x...]
n7[predictions.append(np.max(pred))]
n8[]
n9[return np.array(predictions)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;批次前向傳播\n\n Args:\n X: 輸入批次...]
n4[predictions = []]
n5{for x in X}
n6[pred = self.model.forward(x...]
n7[predictions.append(np.max(pred))]
n8[]
n9[return np.array(predictions)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
137. core aiva core ai engine training trainer Function train epoch
flowchart TB
n1([開始])
n2([結束])
n3['訓練一個 epoch\n\n Args:\n X: ...]
n4[n_samples = len(X)]
n5[batch_size = self.config.batch_si...]
n6[total_loss = 0.0]
n7[correct = 0]
n8{for i in range(0, n_sample...}
n9[batch_X = X[i:i + batch_size]]
n10[batch_y = y[i:i + batch_size]]
n11[predictions = self._forward_batch(...]
n12[loss = np.mean((predictions...]
n13[total_loss += loss]
n14[correct += np.sum(np.abs(predictions - batch_y...]
n15[self._backward_batch(batch_X, batch_y, predictions...]
n16[]
n17[avg_loss = total_loss / (n_samp...]
n18[accuracy = correct / n_samples]
n19[return (avg_loss, accuracy)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n16
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n8
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;訓練一個 epoch\n\n Args:\n X: ...]
n4[n_samples = len(X)]
n5[batch_size = self.config.batch_si...]
n6[total_loss = 0.0]
n7[correct = 0]
n8{for i in range(0, n_sample...}
n9[batch_X = X[i:i + batch_size]]
n10[batch_y = y[i:i + batch_size]]
n11[predictions = self._forward_batch(...]
n12[loss = np.mean((predictions...]
n13[total_loss += loss]
n14[correct += np.sum(np.abs(predictions - batch_y...]
n15[self._backward_batch(batch_X, batch_y, predictions...]
n16[]
n17[avg_loss = total_loss / (n_samp...]
n18[accuracy = correct / n_samples]
n19[return (avg_loss, accuracy)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n16
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n8
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
138. core aiva core ai engine training trainer Function validate
flowchart TB
n1([開始])
n2([結束])
n3['驗證模型\n\n Args:\n X: 驗證特徵\n...]
n4[predictions = self._forward_batch(...]
n5[loss = np.mean((predictions...]
n6[accuracy = np.sum(np.abs(predic...]
n7[return (loss, accuracy)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證模型\n\n Args:\n X: 驗證特徵\n...]
n4[predictions = self._forward_batch(...]
n5[loss = np.mean((predictions...]
n6[accuracy = np.sum(np.abs(predic...]
n7[return (loss, accuracy)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
139. core aiva core ai engine training trainer Function get training summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取訓練摘要\n\n Returns:\n 訓練摘要...]
n4[return {'config': {&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取訓練摘要\n\n Returns:\n 訓練摘要...]
n4[return {&#39;config&#39;: {&...]
n1 --> n3
n3 --> n4
n4 --> n2
140. core aiva core ai engine training trainer Function train
flowchart TB
n1([開始])
n2([結束])
n3['訓練模型\n\n Args:\n X_train: ...]
n4[logger.info(f'Starting training: {le...]
n5[best_val_loss = float('inf')]
n6[patience_counter = 0]
n7{for epoch in range(self.config...}
n8[(train_loss, train_acc) = self._train_epoch(X...]
n9[self.training_history['loss'&...]
n10[self.training_history['accuracy&#...]
n11{if X_val is not None and y_val...}
n12[(val_loss, val_acc) = self._validate(X_val...]
n13[self.training_history['val_loss&#...]
n14[self.training_history['val_accuracy&&...]
n15{if val_loss < best_val_loss - ...}
n16[best_val_loss = val_loss]
n17[patience_counter = 0]
n18[patience_counter += 1]
n19[]
n20[logger.info(f'Epoch {epoch + 1}...]
n21{if patience_counter >= self.co...}
n22[logger.info(f'Early stopping at epoch ...]
n23[break]
n24[]
n25[logger.info(f'Epoch {epoch + 1}...]
n26[]
n27[]
n28[final_metrics = {'final_loss'...]
n29[logger.info(f"Training completed: final_loss...]
n30[return final_metrics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n27
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n25
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n26
n25 --> n26
n26 --> n7
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;訓練模型\n\n Args:\n X_train: ...]
n4[logger.info(f&#39;Starting training: {le...]
n5[best_val_loss = float(&#39;inf&#39;)]
n6[patience_counter = 0]
n7{for epoch in range(self.config...}
n8[(train_loss, train_acc) = self._train_epoch(X...]
n9[self.training_history[&#39;loss&#39;&...]
n10[self.training_history[&#39;accuracy&#...]
n11{if X_val is not None and y_val...}
n12[(val_loss, val_acc) = self._validate(X_val...]
n13[self.training_history[&#39;val_loss&#...]
n14[self.training_history[&#39;val_accuracy&&...]
n15{if val_loss &lt; best_val_loss - ...}
n16[best_val_loss = val_loss]
n17[patience_counter = 0]
n18[patience_counter += 1]
n19[]
n20[logger.info(f&#39;Epoch {epoch + 1}...]
n21{if patience_counter &gt;= self.co...}
n22[logger.info(f&#39;Early stopping at epoch ...]
n23[break]
n24[]
n25[logger.info(f&#39;Epoch {epoch + 1}...]
n26[]
n27[]
n28[final_metrics = {&#39;final_loss&#39...]
n29[logger.info(f&quot;Training completed: final_loss...]
n30[return final_metrics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n27
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n25
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n26
n25 --> n26
n26 --> n7
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
141. core aiva core ai integration test Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化測試器\n\n Args:\n ...]
n4[self.aiva_root = Path(aiva_root)]
n5[self.test_results: list[TestResult] = []]
n6[self.bio_agent = BioNeuronRAGAgent(st...]
n7[self.unified_controller = UnifiedAIController(...]
n8[self.nlg_generator = AIVANaturalLanguageG...]
n9[self.multilang_coordinator = MultiLanguageAICoord...]
n10[print('🚀 AI 整合測試器初始化完成')]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化測試器\n\n Args:\n ...]
n4[self.aiva_root = Path(aiva_root)]
n5[self.test_results: list[TestResult] = []]
n6[self.bio_agent = BioNeuronRAGAgent(st...]
n7[self.unified_controller = UnifiedAIController(...]
n8[self.nlg_generator = AIVANaturalLanguageG...]
n9[self.multilang_coordinator = MultiLanguageAICoord...]
n10[print(&#39;🚀 AI 整合測試器初始化完成&#39;)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
142. core aiva core ai integration test Function generate recommendations
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據失敗的測試生成建議\n\n Args:\n ...]
n4[recommendations = []]
n5{if not failed_tests}
n6[recommendations.append('🎉 所有測試都通過了!AI 整合系...]
n7[return recommendations]
n8[]
n9{for test in failed_tests}
n10{if '初始化' in test.test_name}
n11[recommendations.append('🔧 建議檢查各 AI 組件的初始化...]
n12{if '協調' in test.test_name}
n13[recommendations.append('⚙️ 建議優化統一控制器的任務分配...]
n14{if '自然語言' in test.test_name}
n15[recommendations.append('📝 建議檢查 NLG 系統的模板配...]
n16{if '多語言' in test.test_name}
n17[recommendations.append('🌐 建議檢查多語言協調器的語言模組...]
n18{if '衝突' in test.test_name}
n19[recommendations.append('⚠️ 建議增強 AI 衝突檢測和去...]
n20{if '端到端' in test.test_name}
n21[recommendations.append('🔄 建議檢查整個 AI 處理流程的...]
n22{if '效能' in test.test_name}
n23[recommendations.append('⚡ 建議優化系統效能和並發處理能力...]
n24{if '錯誤恢復' in test.test_name}
n25[recommendations.append('🛡️ 建議增強錯誤處理和恢復機制。...]
n26[]
n27[]
n28[]
n29[]
n30[]
n31[]
n32[]
n33[]
n34[]
n35[return list(set(recommendations))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n34
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n33
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n32
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n31
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n30
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n29
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n28
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n27
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n9
n34 --> n35
n35 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據失敗的測試生成建議\n\n Args:\n ...]
n4[recommendations = []]
n5{if not failed_tests}
n6[recommendations.append(&#39;🎉 所有測試都通過了!AI 整合系...]
n7[return recommendations]
n8[]
n9{for test in failed_tests}
n10{if &#39;初始化&#39; in test.test_name}
n11[recommendations.append(&#39;🔧 建議檢查各 AI 組件的初始化...]
n12{if &#39;協調&#39; in test.test_name}
n13[recommendations.append(&#39;⚙️ 建議優化統一控制器的任務分配...]
n14{if &#39;自然語言&#39; in test.test_name}
n15[recommendations.append(&#39;📝 建議檢查 NLG 系統的模板配...]
n16{if &#39;多語言&#39; in test.test_name}
n17[recommendations.append(&#39;🌐 建議檢查多語言協調器的語言模組...]
n18{if &#39;衝突&#39; in test.test_name}
n19[recommendations.append(&#39;⚠️ 建議增強 AI 衝突檢測和去...]
n20{if &#39;端到端&#39; in test.test_name}
n21[recommendations.append(&#39;🔄 建議檢查整個 AI 處理流程的...]
n22{if &#39;效能&#39; in test.test_name}
n23[recommendations.append(&#39;⚡ 建議優化系統效能和並發處理能力...]
n24{if &#39;錯誤恢復&#39; in test.test_name}
n25[recommendations.append(&#39;🛡️ 建議增強錯誤處理和恢復機制。...]
n26[]
n27[]
n28[]
n29[]
n30[]
n31[]
n32[]
n33[]
n34[]
n35[return list(set(recommendations))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n34
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n33
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n32
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n31
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n30
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n29
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n28
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n27
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n9
n34 --> n35
n35 --> n2
143. core aiva core ai integration test Function generate test report
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成測試報告\n\n Args:\n ...]
n4[successful_tests = [r for r in self.tes...]
n5[failed_tests = [r for r in self.tes...]
n6[report = {'summary': {&...]
n7[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成測試報告\n\n Args:\n ...]
n4[successful_tests = [r for r in self.tes...]
n5[failed_tests = [r for r in self.tes...]
n6[report = {&#39;summary&#39;: {&...]
n7[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
144. core aiva core ai model train classifier Function create database
flowchart TB
n1([開始])
n2([結束])
n3[os.makedirs(os.path.dirname(db_path), exist_o...]
n4[conn = sqlite3.connect(db_p...]
n5[cur = conn.cursor()]
n6[cur.execute('\n CREATE TABLE IF NO...]
n7[conn.commit()]
n8[cur.execute('SELECT COUNT(*) FROM...]
n9[count = cur.fetchone()[0]]
n10{if count == 0}
n11[samples = [("<script>alert...]
n12[cur.executemany('INSERT INTO vulnerabilit...]
n13[conn.commit()]
n14[]
n15[conn.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[os.makedirs(os.path.dirname(db_path), exist_o...]
n4[conn = sqlite3.connect(db_p...]
n5[cur = conn.cursor()]
n6[cur.execute(&#39;\n CREATE TABLE IF NO...]
n7[conn.commit()]
n8[cur.execute(&#39;SELECT COUNT(*) FROM...]
n9[count = cur.fetchone()[0]]
n10{if count == 0}
n11[samples = [(&quot;&lt;script&gt;alert...]
n12[cur.executemany(&#39;INSERT INTO vulnerabilit...]
n13[conn.commit()]
n14[]
n15[conn.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
145. core aiva core ai model train classifier Function load data
flowchart TB
n1([開始])
n2([結束])
n3[conn = sqlite3.connect(db_p...]
n4[cur = conn.cursor()]
n5[cur.execute('SELECT text, label FROM vuln...]
n6[records = cur.fetchall()]
n7[conn.close()]
n8[return ([row[0] for row in records], ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[conn = sqlite3.connect(db_p...]
n4[cur = conn.cursor()]
n5[cur.execute(&#39;SELECT text, label FROM vuln...]
n6[records = cur.fetchall()]
n7[conn.close()]
n8[return ([row[0] for row in records], ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
146. core aiva core ai model train classifier Function train and save model
flowchart TB
n1([開始])
n2([結束])
n3[(texts, labels) = load_data(db_path)]
n4{if not texts or not labels}
n5[raise ValueError('Dataset is empty; pleas...]
n6[]
n7[vectorizer = TfidfVectorizer()]
n8[X = vectorizer.fit_trans...]
n9[y = labels]
n10[(X_train, X_test, y_train, y_test) = train_test_s...]
n11[classifier = LogisticRegression(m...]
n12[classifier.fit(X_train, y_train)]
n13[y_pred = classifier.predict(X...]
n14[acc = accuracy_score(y_tes...]
n15[print(f'Test accuracy: {acc:.2f}...]
n16[print('Classification report:'...]
n17[print(classification_report(y_test, y_pred))]
n18[os.makedirs(os.path.dirname(model_path), exis...]
n19[joblib.dump(classifier, model_path)]
n20[joblib.dump(vectorizer, vectorizer_path)]
n21[return acc]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[(texts, labels) = load_data(db_path)]
n4{if not texts or not labels}
n5[raise ValueError(&#39;Dataset is empty; pleas...]
n6[]
n7[vectorizer = TfidfVectorizer()]
n8[X = vectorizer.fit_trans...]
n9[y = labels]
n10[(X_train, X_test, y_train, y_test) = train_test_s...]
n11[classifier = LogisticRegression(m...]
n12[classifier.fit(X_train, y_train)]
n13[y_pred = classifier.predict(X...]
n14[acc = accuracy_score(y_tes...]
n15[print(f&#39;Test accuracy: {acc:.2f}...]
n16[print(&#39;Classification report:&#39...]
n17[print(classification_report(y_test, y_pred))]
n18[os.makedirs(os.path.dirname(model_path), exis...]
n19[joblib.dump(classifier, model_path)]
n20[joblib.dump(vectorizer, vectorizer_path)]
n21[return acc]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
147. core aiva core ai ui schemas Function validate confidence
flowchart TB
n1([開始])
n2([結束])
n3['驗證信心度.']
n4{if not 0.0 <= v <= 1.0}
n5[raise ValueError('Confidence must be betw...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證信心度.&#39;]
n4{if not 0.0 &lt;= v &lt;= 1.0}
n5[raise ValueError(&#39;Confidence must be betw...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
148. core aiva core ai ui schemas Function validate execution time
flowchart TB
n1([開始])
n2([結束])
n3['驗證執行時間.']
n4{if v is not None and v < 0}
n5[raise ValueError('Execution time cannot b...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證執行時間.&#39;]
n4{if v is not None and v &lt; 0}
n5[raise ValueError(&#39;Execution time cannot b...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
149. core aiva core ai ui schemas Function validate path
flowchart TB
n1([開始])
n2([結束])
n3['驗證路徑.']
n4{if not v.strip()}
n5[raise ValueError('Path cannot be empty&am...]
n6[]
n7{if '..' in v or v.startswith(...}
n8[raise ValueError('Invalid path: directory...]
n9[]
n10[return v.strip()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證路徑.&#39;]
n4{if not v.strip()}
n5[raise ValueError(&#39;Path cannot be empty&am...]
n6[]
n7{if &#39;..&#39; in v or v.startswith(...}
n8[raise ValueError(&#39;Invalid path: directory...]
n9[]
n10[return v.strip()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
150. core aiva core ai ui schemas Function validate port
flowchart TB
n1([開始])
n2([結束])
n3['驗證埠號.']
n4{if not 1024 <= v <= 65535}
n5[raise ValueError('Port must be between 10...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證埠號.&#39;]
n4{if not 1024 &lt;= v &lt;= 65535}
n5[raise ValueError(&#39;Port must be between 10...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
151. core aiva core ai ui schemas Function validate query
flowchart TB
n1([開始])
n2([結束])
n3['驗證查詢字串.']
n4{if not v.strip()}
n5[raise ValueError('Query cannot be empty&a...]
n6[]
n7[return v.strip()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證查詢字串.&#39;]
n4{if not v.strip()}
n5[raise ValueError(&#39;Query cannot be empty&a...]
n6[]
n7[return v.strip()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
152. core aiva core ai ui schemas Function validate score
flowchart TB
n1([開始])
n2([結束])
n3['驗證分數.']
n4{if v < 0}
n5[raise ValueError('Score cannot be negativ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證分數.&#39;]
n4{if v &lt; 0}
n5[raise ValueError(&#39;Score cannot be negativ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
153. core aiva core ai ui schemas Function validate target
flowchart TB
n1([開始])
n2([結束])
n3['驗證目標.']
n4{if not v.strip()}
n5[raise ValueError('Target cannot be empty&...]
n6[]
n7[return v.strip()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證目標.&#39;]
n4{if not v.strip()}
n5[raise ValueError(&#39;Target cannot be empty&...]
n6[]
n7[return v.strip()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
154. core aiva core ai ui schemas Function validate tool name
flowchart TB
n1([開始])
n2([結束])
n3['驗證工具名稱.']
n4[valid_tools = {'CodeReader',...]
n5{if v not in valid_tools}
n6[raise ValueError(f'Invalid tool name: ...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證工具名稱.&#39;]
n4[valid_tools = {&#39;CodeReader&#39;,...]
n5{if v not in valid_tools}
n6[raise ValueError(f&#39;Invalid tool name: ...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
155. core aiva core ai ui schemas Function validate url
flowchart TB
n1([開始])
n2([結束])
n3['驗證 URL 格式.']
n4{if not v.startswith(('http://&...}
n5[raise ValueError('URL must start with htt...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 URL 格式.&#39;]
n4{if not v.startswith((&#39;http://&...}
n5[raise ValueError(&#39;URL must start with htt...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
156. core aiva core analysis ast trace comparator Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化對比分析器']
n4[logger.info('ASTTraceComparator initializ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化對比分析器&#39;]
n4[logger.info(&#39;ASTTraceComparator initializ...]
n1 --> n3
n3 --> n4
n4 --> n2
157. core aiva core analysis ast trace comparator Function calculate completion
flowchart TB
n1([開始])
n2([結束])
n3['計算完成情況\n\n Args:\n expecte...]
n4[expected_actions = {step['action&...]
n5[actual_actions = {step['action&&...]
n6[completed = list(expected_action...]
n7[missing = list(expected_action...]
n8[return (completed, missing)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算完成情況\n\n Args:\n expecte...]
n4[expected_actions = {step[&#39;action&...]
n5[actual_actions = {step[&#39;action&&...]
n6[completed = list(expected_action...]
n7[missing = list(expected_action...]
n8[return (completed, missing)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
158. core aiva core analysis ast trace comparator Function calculate overall score
flowchart TB
n1([開始])
n2([結束])
n3['計算綜合評分\n\n Args:\n complet...]
n4[score = 0.5 * completion_rat...]
n5[return min(1.0, max(0.0, score))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算綜合評分\n\n Args:\n complet...]
n4[score = 0.5 * completion_rat...]
n5[return min(1.0, max(0.0, score))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
159. core aiva core analysis ast trace comparator Function calculate sequence match
flowchart TB
n1([開始])
n2([結束])
n3['計算順序匹配率\n\n Args:\n expect...]
n4{if not expected or not actual}
n5[return (0.0, 0)]
n6[]
n7[expected_sequence = [s['action&...]
n8[actual_sequence = [s['action&#...]
n9[lcs_length = self._longest_common...]
n10[match_rate = lcs_length / len(exp...]
n11[out_of_order = len(expected_sequenc...]
n12[return (match_rate, out_of_order)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算順序匹配率\n\n Args:\n expect...]
n4{if not expected or not actual}
n5[return (0.0, 0)]
n6[]
n7[expected_sequence = [s[&#39;action&&#...]
n8[actual_sequence = [s[&#39;action&#...]
n9[lcs_length = self._longest_common...]
n10[match_rate = lcs_length / len(exp...]
n11[out_of_order = len(expected_sequenc...]
n12[return (match_rate, out_of_order)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
160. core aiva core analysis ast trace comparator Function calculate timing
flowchart TB
n1([開始])
n2([結束])
n3['計算時間指標\n\n Args:\n trace: ...]
n4{if not trace.end_time}
n5[return (None, None)]
n6[]
n7[duration = (trace.end_time - tr...]
n8[task_starts = trace.get_entries_by...]
n9[avg_duration = duration / len(task_...]
n10[return (duration, avg_duration)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算時間指標\n\n Args:\n trace: ...]
n4{if not trace.end_time}
n5[return (None, None)]
n6[]
n7[duration = (trace.end_time - tr...]
n8[task_starts = trace.get_entries_by...]
n9[avg_duration = duration / len(task_...]
n10[return (duration, avg_duration)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
161. core aiva core analysis ast trace comparator Function count success failure
flowchart TB
n1([開始])
n2([結束])
n3['統計成功和失敗的步驟\n\n Args:\n tra...]
n4[task_ends = trace.get_entries_by...]
n5[success_count = 0]
n6[failed_count = 0]
n7{for entry in task_ends}
n8{if entry.content.get('success'...}
n9[success_count += 1]
n10[failed_count += 1]
n11[]
n12[]
n13[return (success_count, failed_count)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;統計成功和失敗的步驟\n\n Args:\n tra...]
n4[task_ends = trace.get_entries_by...]
n5[success_count = 0]
n6[failed_count = 0]
n7{for entry in task_ends}
n8{if entry.content.get(&#39;success&#39...}
n9[success_count += 1]
n10[failed_count += 1]
n11[]
n12[]
n13[return (success_count, failed_count)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n2
162. core aiva core analysis ast trace comparator Function extract actual steps
flowchart TB
n1([開始])
n2([結束])
n3['從 Trace 提取實際步驟\n\n Args:\n ...]
n4[steps = []]
n5[task_starts = trace.get_entries_by...]
n6{for entry in task_starts}
n7[steps.append({'task_id':...]
n8[]
n9[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從 Trace 提取實際步驟\n\n Args:\n ...]
n4[steps = []]
n5[task_starts = trace.get_entries_by...]
n6{for entry in task_starts}
n7[steps.append({&#39;task_id&#39;:...]
n8[]
n9[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n2
163. core aiva core analysis ast trace comparator Function extract expected steps
flowchart TB
n1([開始])
n2([結束])
n3['從 AST 提取預期步驟\n\n Args:\n g...]
n4[steps = []]
n5{for node in graph.nodes.values()}
n6{if node.node_type in (NodeType...}
n7[continue]
n8[]
n9[steps.append({'node_id':...]
n10[]
n11[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從 AST 提取預期步驟\n\n Args:\n g...]
n4[steps = []]
n5{for node in graph.nodes.values()}
n6{if node.node_type in (NodeType...}
n7[continue]
n8[]
n9[steps.append({&#39;node_id&#39;:...]
n10[]
n11[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
164. core aiva core analysis ast trace comparator Function find extra steps
flowchart TB
n1([開始])
n2([結束])
n3['找出額外的步驟\n\n Args:\n expect...]
n4[expected_actions = {step['action&...]
n5[actual_actions = {step['action&&...]
n6[extra = list(actual_actions ...]
n7[return extra]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;找出額外的步驟\n\n Args:\n expect...]
n4[expected_actions = {step[&#39;action&...]
n5[actual_actions = {step[&#39;action&&...]
n6[extra = list(actual_actions ...]
n7[return extra]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
165. core aiva core analysis ast trace comparator Function longest common subsequence
flowchart TB
n1([開始])
n2([結束])
n3['計算最長公共子序列長度\n\n Args:\n se...]
n4[(m, n) = (len(seq1), len(seq2...]
n5[dp = [[0] * (n + 1) for _...]
n6{for i in range(1, m + 1)}
n7{for j in range(1, n + 1)}
n8{if seq1[i - 1] == seq2[j - 1]}
n9[dp[i][j] = dp[i - 1][j - 1 ...]
n10[dp[i][j] = max(dp[i - 1][...]
n11[]
n12[]
n13[]
n14[return dp[m][n]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n6
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算最長公共子序列長度\n\n Args:\n se...]
n4[(m, n) = (len(seq1), len(seq2...]
n5[dp = [[0] * (n + 1) for _...]
n6{for i in range(1, m + 1)}
n7{for j in range(1, n + 1)}
n8{if seq1[i - 1] == seq2[j - 1]}
n9[dp[i][j] = dp[i - 1][j - 1	...]
n10[dp[i][j] = max(dp[i - 1][...]
n11[]
n12[]
n13[]
n14[return dp[m][n]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n6
n13 --> n14
n14 --> n2
166. core aiva core analysis ast trace comparator Function compare
flowchart TB
n1([開始])
n2([結束])
n3['比較 AST 與 Trace\n\n Args:\n ...]
n4[logger.info(f"Comparing AST graph &#...]
n5[expected_steps = self._extract_expect...]
n6[actual_steps = self._extract_actual...]
n7[(completed, missing) = self._calculate_comp...]
n8[completion_rate = len(completed) / len...]
n9[(sequence_match_rate, out_of_order) = self._calcu...]
n10[extra_steps = self._find_extra_ste...]
n11[(success_count, failed_count) = self._count_succe...]
n12[error_count = len(actual_trace.get...]
n13[(duration, avg_duration) = self._calculate_timi...]
n14[overall_score = self._calculate_over...]
n15[metrics = ComparisonMetrics(ex...]
n16[logger.info(f'Comparison complete: comple...]
n17[return metrics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;比較 AST 與 Trace\n\n Args:\n ...]
n4[logger.info(f&quot;Comparing AST graph &#...]
n5[expected_steps = self._extract_expect...]
n6[actual_steps = self._extract_actual...]
n7[(completed, missing) = self._calculate_comp...]
n8[completion_rate = len(completed) / len...]
n9[(sequence_match_rate, out_of_order) = self._calcu...]
n10[extra_steps = self._find_extra_ste...]
n11[(success_count, failed_count) = self._count_succe...]
n12[error_count = len(actual_trace.get...]
n13[(duration, avg_duration) = self._calculate_timi...]
n14[overall_score = self._calculate_over...]
n15[metrics = ComparisonMetrics(ex...]
n16[logger.info(f&#39;Comparison complete: comple...]
n17[return metrics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
167. core aiva core analysis ast trace comparator Function generate feedback
flowchart TB
n1([開始])
n2([結束])
n3['生成回饋信號\n\n 用於強化學習的獎勵/懲罰信號\n\n ...]
n4[reward = metrics.overall_scor...]
n5[suggestions = []]
n6{if metrics.completion_rate < 0.8}
n7[suggestions.append('增加步驟完成率'&...]
n8[]
n9{if metrics.sequence_match_rate...}
n10[suggestions.append('改善步驟執行順序'...]
n11[]
n12{if metrics.error_count > 0}
n13[suggestions.append(f'減少錯誤(當前:{metric...]
n14[]
n15{if metrics.failed_steps > 0}
n16[suggestions.append(f'提高步驟成功率(失敗:{met...]
n17[]
n18[feedback = {'reward': reward...]
n19[return feedback]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成回饋信號\n\n 用於強化學習的獎勵/懲罰信號\n\n ...]
n4[reward = metrics.overall_scor...]
n5[suggestions = []]
n6{if metrics.completion_rate &lt; 0.8}
n7[suggestions.append(&#39;增加步驟完成率&#39;&...]
n8[]
n9{if metrics.sequence_match_rate...}
n10[suggestions.append(&#39;改善步驟執行順序&#39;...]
n11[]
n12{if metrics.error_count &gt; 0}
n13[suggestions.append(f&#39;減少錯誤(當前:{metric...]
n14[]
n15{if metrics.failed_steps &gt; 0}
n16[suggestions.append(f&#39;提高步驟成功率(失敗:{met...]
n17[]
n18[feedback = {&#39;reward&#39;: reward...]
n19[return feedback]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
168. core aiva core analysis ast trace comparator Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典']
n4[return asdict(self)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典&#39;]
n4[return asdict(self)]
n1 --> n3
n3 --> n4
n4 --> n2
169. core aiva core analysis dynamic strategy adjustment Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._learning_data: dict[str, list[dict[str,...]
n4[self._waf_patterns: dict[str, list[str]] ...]
n5[self._success_patterns: dict[str, list[dict[s...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._learning_data: dict[str, list[dict[str,...]
n4[self._waf_patterns: dict[str, list[str]] ...]
n5[self._success_patterns: dict[str, list[dict[s...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
170. core aiva core analysis dynamic strategy adjustment Function adjust based on success rate
flowchart TB
n1([開始])
n2([結束])
n3['基於成功率調整']
n4[scan_id = str(context.get('sca...]
n5[learning_data = self._learning_data....]
n6{if not learning_data}
n7[return plan]
n8[]
n9[module_stats = {}]
n10{for data in learning_data}
n11[module = data.get('module')]
n12[success = data.get('success',...]
n13{if module not in module_stats}
n14[module_stats[module] = {'total&a...]
n15[]
n16[module_stats[module]['total&&...]
n17{if success}
n18[module_stats[module]['success&...]
n19[]
n20[]
n21{for task in plan.get('tasks',...}
n22[task_type = task.get('type')]
n23{if task_type in module_stats}
n24[success_rate = module_stats[task_ty...]
n25{if success_rate > 0.7}
n26[task['priority'] = min...]
n27{if success_rate < 0.3}
n28[task['priority'] = max...]
n29[]
n30[]
n31[]
n32[]
n33[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n20
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n10
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n32
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n31
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n21
n32 --> n33
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;基於成功率調整&#39;]
n4[scan_id = str(context.get(&#39;sca...]
n5[learning_data = self._learning_data....]
n6{if not learning_data}
n7[return plan]
n8[]
n9[module_stats = {}]
n10{for data in learning_data}
n11[module = data.get(&#39;module&#39;)]
n12[success = data.get(&#39;success&#39;,...]
n13{if module not in module_stats}
n14[module_stats[module] = {&#39;total&a...]
n15[]
n16[module_stats[module][&#39;total&&...]
n17{if success}
n18[module_stats[module][&#39;success&...]
n19[]
n20[]
n21{for task in plan.get(&#39;tasks&#39;,...}
n22[task_type = task.get(&#39;type&#39;)]
n23{if task_type in module_stats}
n24[success_rate = module_stats[task_ty...]
n25{if success_rate &gt; 0.7}
n26[task[&#39;priority&#39;] = min...]
n27{if success_rate &lt; 0.3}
n28[task[&#39;priority&#39;] = max...]
n29[]
n30[]
n31[]
n32[]
n33[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n20
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n10
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n32
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n31
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n21
n32 --> n33
n33 --> n2
171. core aiva core analysis dynamic strategy adjustment Function adjust for findings
flowchart TB
n1([開始])
n2([結束])
n3['基於已發現漏洞調整']
n4[findings_count = context.get('finding...]
n5{if findings_count > 3}
n6{for task in plan.get('tasks',...}
n7{if task.get('priority', 5)...}
n8[task['priority'] = max...]
n9[]
n10[]
n11[]
n12[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n6
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;基於已發現漏洞調整&#39;]
n4[findings_count = context.get(&#39;finding...]
n5{if findings_count &gt; 3}
n6{for task in plan.get(&#39;tasks&#39;,...}
n7{if task.get(&#39;priority&#39;, 5)...}
n8[task[&#39;priority&#39;] = max...]
n9[]
n10[]
n11[]
n12[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n6
n10 --> n11
n11 --> n12
n12 --> n2
172. core aiva core analysis dynamic strategy adjustment Function adjust for tech stack
flowchart TB
n1([開始])
n2([結束])
n3['基於技術棧調整']
n4[web_server = fingerprints.get('we...]
n5[framework = fingerprints.get('fr...]
n6{if 'nginx' in web_server}
n7{for task in plan.get('tasks',...}
n8{if task.get('type') == &a...}
n9[task['check_nginx_vars'] ...]
n10[]
n11[]
n12[]
n13{if 'django' in framework}
n14{for task in plan.get('tasks',...}
n15{if task.get('type') == &a...}
n16[task['check_csrf_token'] ...]
n17[]
n18[]
n19[]
n20{if 'php' in fingerprints.get(...}
n21{for task in plan.get('tasks',...}
n22{if task.get('type') == &a...}
n23[task['php_wrappers'] = True]
n24[]
n25[]
n26[]
n27[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 -->|Yes| n15
n14 -->|No| n18
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n14
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n26
n21 -->|Yes| n22
n21 -->|No| n25
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n21
n25 --> n26
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;基於技術棧調整&#39;]
n4[web_server = fingerprints.get(&#39;we...]
n5[framework = fingerprints.get(&#39;fr...]
n6{if &#39;nginx&#39; in web_server}
n7{for task in plan.get(&#39;tasks&#39;,...}
n8{if task.get(&#39;type&#39;) == &a...}
n9[task[&#39;check_nginx_vars&#39;] ...]
n10[]
n11[]
n12[]
n13{if &#39;django&#39; in framework}
n14{for task in plan.get(&#39;tasks&#39;,...}
n15{if task.get(&#39;type&#39;) == &a...}
n16[task[&#39;check_csrf_token&#39;] ...]
n17[]
n18[]
n19[]
n20{if &#39;php&#39; in fingerprints.get(...}
n21{for task in plan.get(&#39;tasks&#39;,...}
n22{if task.get(&#39;type&#39;) == &a...}
n23[task[&#39;php_wrappers&#39;] = True]
n24[]
n25[]
n26[]
n27[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 -->|Yes| n15
n14 -->|No| n18
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n14
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n26
n21 -->|Yes| n22
n21 -->|No| n25
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n21
n25 --> n26
n26 --> n27
n27 --> n2
173. core aiva core analysis dynamic strategy adjustment Function adjust for waf
flowchart TB
n1([開始])
n2([結束])
n3['WAF適應調整']
n4[waf_vendor = context.get('fingerp...]
n5{if waf_vendor}
n6[logger.info(f'Adjusting strategy for WAF:...]
n7{if 'timing' in plan}
n8[plan['timing'][&&...]
n9[plan['timing'] = {&a...]
n10[]
n11{for task in plan.get('tasks',...}
n12{if task.get('type') in ...}
n13[task['use_evasion'] = True]
n14[task['payload_type'] = &a...]
n15[]
n16[]
n17[]
n18[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n11
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;WAF適應調整&#39;]
n4[waf_vendor = context.get(&#39;fingerp...]
n5{if waf_vendor}
n6[logger.info(f&#39;Adjusting strategy for WAF:...]
n7{if &#39;timing&#39; in plan}
n8[plan[&#39;timing&#39;][&&...]
n9[plan[&#39;timing&#39;] = {&a...]
n10[]
n11{for task in plan.get(&#39;tasks&#39;,...}
n12{if task.get(&#39;type&#39;) in &#...}
n13[task[&#39;use_evasion&#39;] = True]
n14[task[&#39;payload_type&#39;] = &a...]
n15[]
n16[]
n17[]
n18[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n11
n16 --> n17
n17 --> n18
n18 --> n2
174. core aiva core analysis dynamic strategy adjustment Function adjust
flowchart TB
n1([開始])
n2([結束])
n3['\n 動態調整測試策略\n\n Args:\n ...]
n4[adjusted_plan = plan.copy()]
n5{if context.get('waf_detected'...}
n6[adjusted_plan = self._adjust_for_waf...]
n7[]
n8[adjusted_plan = self._adjust_based_o...]
n9{if context.get('fingerprints'...}
n10[adjusted_plan = self._adjust_for_tec...]
n11[]
n12{if context.get('findings_count...}
n13[adjusted_plan = self._adjust_for_fin...]
n14[]
n15[logger.info(f"Strategy adjusted for scan ...]
n16[return adjusted_plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 動態調整測試策略\n\n Args:\n ...]
n4[adjusted_plan = plan.copy()]
n5{if context.get(&#39;waf_detected&#39;...}
n6[adjusted_plan = self._adjust_for_waf...]
n7[]
n8[adjusted_plan = self._adjust_based_o...]
n9{if context.get(&#39;fingerprints&#39;...}
n10[adjusted_plan = self._adjust_for_tec...]
n11[]
n12{if context.get(&#39;findings_count...}
n13[adjusted_plan = self._adjust_for_fin...]
n14[]
n15[logger.info(f&quot;Strategy adjusted for scan ...]
n16[return adjusted_plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
175. core aiva core analysis dynamic strategy adjustment Function learn from result
flowchart TB
n1([開始])
n2([結束])
n3['\n 從測試結果中學習,更新策略知識庫\n\n Args:\...]
n4[scan_id = feedback_data.get('s...]
n5[module = feedback_data.get('m...]
n6[success = feedback_data.get('s...]
n7{if not scan_id or not module}
n8[return]
n9[]
n10{if scan_id not in self._learni...}
n11[self._learning_data[scan_id] = []]
n12[]
n13[self._learning_data[scan_id].append(feedback_...]
n14{if success and module}
n15{if module not in self._success...}
n16[self._success_patterns[module] = []]
n17[]
n18[self._success_patterns[module].append(feedbac...]
n19[]
n20[logger.info(f"Learned from {module}...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n19
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 從測試結果中學習,更新策略知識庫\n\n Args:\...]
n4[scan_id = feedback_data.get(&#39;s...]
n5[module = feedback_data.get(&#39;m...]
n6[success = feedback_data.get(&#39;s...]
n7{if not scan_id or not module}
n8[return]
n9[]
n10{if scan_id not in self._learni...}
n11[self._learning_data[scan_id] = []]
n12[]
n13[self._learning_data[scan_id].append(feedback_...]
n14{if success and module}
n15{if module not in self._success...}
n16[self._success_patterns[module] = []]
n17[]
n18[self._success_patterns[module].append(feedbac...]
n19[]
n20[logger.info(f&quot;Learned from {module}...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n19
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
176. core aiva core analysis initial surface Function calculate risk score
flowchart TB
n1([開始])
n2([結束])
n3['計算資產風險評分 (0-100)']
n4[score = 50]
n5{if asset.has_form}
n6[score += 20]
n7[]
n8[param_count = len(asset.parameters...]
n9{if param_count > 5}
n10[score += 15]
n11{if param_count > 2}
n12[score += 10]
n13{if param_count > 0}
n14[score += 5]
n15[]
n16[]
n17[]
n18[parameters = [p.lower() for p in ...]
n19[sensitive_keywords = {'id', ...]
n20{if any((kw in param for param ...}
n21[score += 15]
n22[]
n23[return min(score, 100)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算資產風險評分 (0-100)&#39;]
n4[score = 50]
n5{if asset.has_form}
n6[score += 20]
n7[]
n8[param_count = len(asset.parameters...]
n9{if param_count &gt; 5}
n10[score += 15]
n11{if param_count &gt; 2}
n12[score += 10]
n13{if param_count &gt; 0}
n14[score += 5]
n15[]
n16[]
n17[]
n18[parameters = [p.lower() for p in ...]
n19[sensitive_keywords = {&#39;id&#39;, ...]
n20{if any((kw in param for param ...}
n21[score += 15]
n22[]
n23[return min(score, 100)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n2
177. core aiva core analysis initial surface Function detect idor candidates
flowchart TB
n1([開始])
n2([結束])
n3['檢測 IDOR 漏洞候選']
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = 'body' if asset.has_...]
n9[candidates: list[IdorCandidate] = []]
n10{for parameter in parameters}
n11[lower_name = parameter.lower()]
n12[keyword_hits = [hint for hint in se...]
n13{if keyword_hits}
n14[confidence = 0.6 if 'id' in keywo...]
n15[reasons = [f"Parameter '{pa...]
n16[id_pattern = 'numeric' if &...]
n17[candidates.append(IdorCandidate(asset_url=str(...]
n18[]
n19[]
n20[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n19
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n10
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 IDOR 漏洞候選&#39;]
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = &#39;body&#39; if asset.has_...]
n9[candidates: list[IdorCandidate] = []]
n10{for parameter in parameters}
n11[lower_name = parameter.lower()]
n12[keyword_hits = [hint for hint in se...]
n13{if keyword_hits}
n14[confidence = 0.6 if &#39;id&#39; in keywo...]
n15[reasons = [f&quot;Parameter &#39;{pa...]
n16[id_pattern = &#39;numeric&#39; if &&#...]
n17[candidates.append(IdorCandidate(asset_url=str(...]
n18[]
n19[]
n20[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n19
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n10
n19 --> n20
n20 --> n2
178. core aiva core analysis initial surface Function detect sqli candidates
flowchart TB
n1([開始])
n2([結束])
n3['檢測 SQLi 漏洞候選']
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = 'body' if asset.has_...]
n9[candidates: list[SqliCandidate] = []]
n10{for parameter in parameters}
n11[lower_name = parameter.lower()]
n12[keyword_hits = [hint for hint in se...]
n13{if keyword_hits}
n14[confidence = 0.7 if 'id' in keywo...]
n15[reasons = [f"Parameter '{pa...]
n16[candidates.append(SqliCandidate(asset_url=str(...]
n17[]
n18[]
n19[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n10
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 SQLi 漏洞候選&#39;]
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = &#39;body&#39; if asset.has_...]
n9[candidates: list[SqliCandidate] = []]
n10{for parameter in parameters}
n11[lower_name = parameter.lower()]
n12[keyword_hits = [hint for hint in se...]
n13{if keyword_hits}
n14[confidence = 0.7 if &#39;id&#39; in keywo...]
n15[reasons = [f&quot;Parameter &#39;{pa...]
n16[candidates.append(SqliCandidate(asset_url=str(...]
n17[]
n18[]
n19[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n10
n18 --> n19
n19 --> n2
179. core aiva core analysis initial surface Function detect ssrf candidates
flowchart TB
n1([開始])
n2([結束])
n3['檢測 SSRF 漏洞候選']
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = 'body' if asset.has_...]
n9[path = str(asset.value).low...]
n10[path_hints = [hint for hint in se...]
n11[candidates: list[SsrfCandidate] = []]
n12{for parameter in parameters}
n13[reasons = self._evaluate_param...]
n14{if not reasons}
n15[continue]
n16[]
n17[confidence = 0.7 if any(('callbac...]
n18[candidates.append(SsrfCandidate(asset_url=str(...]
n19[]
n20[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n19
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n12
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 SSRF 漏洞候選&#39;]
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = &#39;body&#39; if asset.has_...]
n9[path = str(asset.value).low...]
n10[path_hints = [hint for hint in se...]
n11[candidates: list[SsrfCandidate] = []]
n12{for parameter in parameters}
n13[reasons = self._evaluate_param...]
n14{if not reasons}
n15[continue]
n16[]
n17[confidence = 0.7 if any((&#39;callbac...]
n18[candidates.append(SsrfCandidate(asset_url=str(...]
n19[]
n20[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n19
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n12
n19 --> n20
n20 --> n2
180. core aiva core analysis initial surface Function detect xss candidates
flowchart TB
n1([開始])
n2([結束])
n3['檢測 XSS 漏洞候選']
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = 'body' if asset.has_...]
n9[candidates: list[XssCandidate] = []]
n10{for parameter in parameters}
n11[lower_name = parameter.lower()]
n12[keyword_hits = [hint for hint in se...]
n13{if keyword_hits}
n14[confidence = 0.6 if len(keyword_h...]
n15[reasons = [f"Parameter '{pa...]
n16[candidates.append(XssCandidate(asset_url=str(...]
n17[]
n18[]
n19[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n10
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 XSS 漏洞候選&#39;]
n4[parameters = list(asset.parameter...]
n5{if not parameters}
n6[return []]
n7[]
n8[location = &#39;body&#39; if asset.has_...]
n9[candidates: list[XssCandidate] = []]
n10{for parameter in parameters}
n11[lower_name = parameter.lower()]
n12[keyword_hits = [hint for hint in se...]
n13{if keyword_hits}
n14[confidence = 0.6 if len(keyword_h...]
n15[reasons = [f&quot;Parameter &#39;{pa...]
n16[candidates.append(XssCandidate(asset_url=str(...]
n17[]
n18[]
n19[return candidates]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n10
n18 --> n19
n19 --> n2
181. core aiva core analysis initial surface Function evaluate parameter
flowchart TB
n1([開始])
n2([結束])
n3[lower_name = parameter.lower()]
n4[keyword_hits = [hint for hint in se...]
n5[reasons: list[str] = []]
n6{if keyword_hits}
n7[reasons.append(f"Parameter '...]
n8[]
n9{if path_hints}
n10[reasons.append('URL path includes SSRF hi...]
n11[]
n12[return reasons]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lower_name = parameter.lower()]
n4[keyword_hits = [hint for hint in se...]
n5[reasons: list[str] = []]
n6{if keyword_hits}
n7[reasons.append(f&quot;Parameter &#39;...]
n8[]
n9{if path_hints}
n10[reasons.append(&#39;URL path includes SSRF hi...]
n11[]
n12[return reasons]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
182. core aiva core analysis initial surface Function summarize asset
flowchart TB
n1([開始])
n2([結束])
n3[return {'asset_id': asset.as...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return {&#39;asset_id&#39;: asset.as...]
n1 --> n3
n3 --> n2
183. core aiva core analysis initial surface Function analyze
flowchart TB
n1([開始])
n2([結束])
n3[forms = sum((1 for a in payl...]
n4[params = sum((len(a.parameter...]
n5[waf = bool(payload.fingerp...]
n6[xss_candidates: list[XssCandidate] = []]
n7[sqli_candidates: list[SqliCandidate] = []]
n8[ssrf_candidates: list[SsrfCandidate] = []]
n9[idor_candidates: list[IdorCandidate] = []]
n10[high_risk_assets: list[AssetAnalysis] = []]
n11[medium_risk_assets: list[AssetAnalysis] = []]
n12[low_risk_assets: list[AssetAnalysis] = []]
n13{for asset in payload.assets}
n14[xss_candidates.extend(self._detect_xss_candidates(...]
n15[sqli_candidates.extend(self._detect_sqli_candidate...]
n16[ssrf_candidates.extend(self._detect_ssrf_candidate...]
n17[idor_candidates.extend(self._detect_idor_candidate...]
n18[risk_score = self._calculate_risk...]
n19[asset_analysis = AssetAnalysis(asset_...]
n20{if risk_score >= 70}
n21[high_risk_assets.append(asset_analysis)]
n22{if risk_score >= 40}
n23[medium_risk_assets.append(asset_analysis)]
n24[low_risk_assets.append(asset_analysis)]
n25[]
n26[]
n27[]
n28[return AttackSurfaceAnalysis(scan_id=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n27
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n26
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n25
n24 --> n25
n25 --> n26
n26 --> n13
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[forms = sum((1 for a in payl...]
n4[params = sum((len(a.parameter...]
n5[waf = bool(payload.fingerp...]
n6[xss_candidates: list[XssCandidate] = []]
n7[sqli_candidates: list[SqliCandidate] = []]
n8[ssrf_candidates: list[SsrfCandidate] = []]
n9[idor_candidates: list[IdorCandidate] = []]
n10[high_risk_assets: list[AssetAnalysis] = []]
n11[medium_risk_assets: list[AssetAnalysis] = []]
n12[low_risk_assets: list[AssetAnalysis] = []]
n13{for asset in payload.assets}
n14[xss_candidates.extend(self._detect_xss_candidates(...]
n15[sqli_candidates.extend(self._detect_sqli_candidate...]
n16[ssrf_candidates.extend(self._detect_ssrf_candidate...]
n17[idor_candidates.extend(self._detect_idor_candidate...]
n18[risk_score = self._calculate_risk...]
n19[asset_analysis = AssetAnalysis(asset_...]
n20{if risk_score &gt;= 70}
n21[high_risk_assets.append(asset_analysis)]
n22{if risk_score &gt;= 40}
n23[medium_risk_assets.append(asset_analysis)]
n24[low_risk_assets.append(asset_analysis)]
n25[]
n26[]
n27[]
n28[return AttackSurfaceAnalysis(scan_id=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n27
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n26
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n25
n24 --> n25
n25 --> n26
n26 --> n13
n27 --> n28
n28 --> n2
184. core aiva core analysis plan comparator Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化對比分析器']
n4[logger.info('PlanComparator initialized&a...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化對比分析器&#39;]
n4[logger.info(&#39;PlanComparator initialized&a...]
n1 --> n3
n3 --> n4
n4 --> n2
185. core aiva core analysis plan comparator Function calculate quality bonus
flowchart TB
n1([開始])
n2([結束])
n3['計算步驟質量加成\n\n Args:\n match...]
n4{if not matches}
n5[return 0.0]
n6[]
n7[exact_matches = sum((1 for m in matc...]
n8[total_expected = sum((1 for m in matc...]
n9{if total_expected == 0}
n10[return 0.0]
n11[]
n12[quality_ratio = exact_matches / tota...]
n13[return min(quality_ratio * 0.1, 0.1)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算步驟質量加成\n\n Args:\n match...]
n4{if not matches}
n5[return 0.0]
n6[]
n7[exact_matches = sum((1 for m in matc...]
n8[total_expected = sum((1 for m in matc...]
n9{if total_expected == 0}
n10[return 0.0]
n11[]
n12[quality_ratio = exact_matches / tota...]
n13[return min(quality_ratio * 0.1, 0.1)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
186. core aiva core analysis plan comparator Function calculate reward score
flowchart TB
n1([開始])
n2([結束])
n3['計算獎勵分數(用於強化學習)\n\n Args:\n ...]
n4[base_score = completion_rate * 0....]
n5[goal_bonus = 0.2 if goal_achieved...]
n6[quality_bonus = self._calculate_qual...]
n7[reward = base_score + goal_bo...]
n8[extra_penalty = min(sum((1 for m in ...]
n9[reward = max(0.0, min(reward ...]
n10[return reward]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算獎勵分數(用於強化學習)\n\n Args:\n ...]
n4[base_score = completion_rate * 0....]
n5[goal_bonus = 0.2 if goal_achieved...]
n6[quality_bonus = self._calculate_qual...]
n7[reward = base_score + goal_bo...]
n8[extra_penalty = min(sum((1 for m in ...]
n9[reward = max(0.0, min(reward ...]
n10[return reward]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
187. core aiva core analysis plan comparator Function calculate sequence accuracy
flowchart TB
n1([開始])
n2([結束])
n3['計算順序準確度\n\n 使用最長公共子序列 (LCS) 算...]
n4[expected_order = [step.step_id for st...]
n5[actual_order = [trace.step_id for t...]
n6{if not expected_order or not a...}
n7[return 0.0]
n8[]
n9[lcs_length = self._lcs_length(exp...]
n10[accuracy = lcs_length / len(exp...]
n11[return accuracy]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算順序準確度\n\n 使用最長公共子序列 (LCS) 算...]
n4[expected_order = [step.step_id for st...]
n5[actual_order = [trace.step_id for t...]
n6{if not expected_order or not a...}
n7[return 0.0]
n8[]
n9[lcs_length = self._lcs_length(exp...]
n10[accuracy = lcs_length / len(exp...]
n11[return accuracy]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
188. core aiva core analysis plan comparator Function calculate step similarity
flowchart TB
n1([開始])
n2([結束])
n3['計算步驟相似度\n\n Args:\n step: ...]
n4[similarity = 0.0]
n5{if step.tool_type == trace.too...}
n6[similarity += 0.4]
n7[]
n8{if step.action.lower() in trac...}
n9[similarity += 0.3]
n10[]
n11{if trace.status == 'success'}
n12[similarity += 0.3]
n13{if trace.status in {'failed'...}
n14[similarity += 0.1]
n15[]
n16[]
n17[return min(similarity, 1.0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算步驟相似度\n\n Args:\n step: ...]
n4[similarity = 0.0]
n5{if step.tool_type == trace.too...}
n6[similarity += 0.4]
n7[]
n8{if step.action.lower() in trac...}
n9[similarity += 0.3]
n10[]
n11{if trace.status == &#39;success&#39;}
n12[similarity += 0.3]
n13{if trace.status in {&#39;failed&#39;...}
n14[similarity += 0.1]
n15[]
n16[]
n17[return min(similarity, 1.0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
189. core aiva core analysis plan comparator Function check critical steps
flowchart TB
n1([開始])
n2([結束])
n3['檢查關鍵步驟是否完成\n\n Args:\n pla...]
n4[critical_step_ids = {step.step_id for st...]
n5{if not critical_step_ids}
n6[return True]
n7[]
n8[completed_critical = {trace.step_id for t...]
n9[return len(completed_critical) == len...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查關鍵步驟是否完成\n\n Args:\n pla...]
n4[critical_step_ids = {step.step_id for st...]
n5{if not critical_step_ids}
n6[return True]
n7[]
n8[completed_critical = {trace.step_id for t...]
n9[return len(completed_critical) == len...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
190. core aiva core analysis plan comparator Function count extra actions
flowchart TB
n1([開始])
n2([結束])
n3['計算額外動作數量\n\n Args:\n match...]
n4[return sum((1 for m in matches if m.m...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算額外動作數量\n\n Args:\n match...]
n4[return sum((1 for m in matches if m.m...]
n1 --> n3
n3 --> n4
n4 --> n2
191. core aiva core analysis plan comparator Function evaluate goal achievement
flowchart TB
n1([開始])
n2([結束])
n3['評估目標達成\n\n Args:\n plan: 攻...]
n4{if completion_rate < 0.8 or su...}
n5[return False]
n6[]
n7{if plan.attack_type.value in {...}
n8[has_findings = any((trace.output_da...]
n9{if not has_findings}
n10[return False]
n11[]
n12[]
n13[return self._check_critical_steps(pla...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;評估目標達成\n\n Args:\n plan: 攻...]
n4{if completion_rate &lt; 0.8 or su...}
n5[return False]
n6[]
n7{if plan.attack_type.value in {...}
n8[has_findings = any((trace.output_da...]
n9{if not has_findings}
n10[return False]
n11[]
n12[]
n13[return self._check_critical_steps(pla...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
192. core aiva core analysis plan comparator Function generate recommendations
flowchart TB
n1([開始])
n2([結束])
n3['生成改進建議\n\n Args:\n metrics...]
n4[recommendations = []]
n5{if metrics.completion_rate < 0.7}
n6[recommendations.append(f'完成率僅 {metri...]
n7[]
n8{if metrics.success_rate < 0.8}
n9[recommendations.append(f'成功率僅 {metri...]
n10[]
n11{if metrics.sequence_accuracy <...}
n12[recommendations.append(f'順序準確度僅 {met...]
n13[]
n14{if metrics.extra_actions > 0}
n15[recommendations.append(f'檢測到 {metric...]
n16[]
n17[missing_steps = sum((1 for m in matc...]
n18{if missing_steps > 0}
n19[recommendations.append(f'有 {missing_...]
n20[]
n21{if not metrics.goal_achieved}
n22[recommendations.append('未達成目標,建議調整攻擊策略或改進...]
n23[]
n24{if not recommendations}
n25[recommendations.append('執行表現良好,無需特別調整&...]
n26[]
n27[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成改進建議\n\n Args:\n metrics...]
n4[recommendations = []]
n5{if metrics.completion_rate &lt; 0.7}
n6[recommendations.append(f&#39;完成率僅 {metri...]
n7[]
n8{if metrics.success_rate &lt; 0.8}
n9[recommendations.append(f&#39;成功率僅 {metri...]
n10[]
n11{if metrics.sequence_accuracy &lt;...}
n12[recommendations.append(f&#39;順序準確度僅 {met...]
n13[]
n14{if metrics.extra_actions &gt; 0}
n15[recommendations.append(f&#39;檢測到 {metric...]
n16[]
n17[missing_steps = sum((1 for m in matc...]
n18{if missing_steps &gt; 0}
n19[recommendations.append(f&#39;有 {missing_...]
n20[]
n21{if not metrics.goal_achieved}
n22[recommendations.append(&#39;未達成目標,建議調整攻擊策略或改進...]
n23[]
n24{if not recommendations}
n25[recommendations.append(&#39;執行表現良好,無需特別調整&...]
n26[]
n27[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n2
193. core aiva core analysis plan comparator Function lcs length
flowchart TB
n1([開始])
n2([結束])
n3['計算最長公共子序列長度\n\n Args:\n se...]
n4[(m, n) = (len(seq1), len(seq2...]
n5[dp = [[0] * (n + 1) for _...]
n6{for i in range(1, m + 1)}
n7{for j in range(1, n + 1)}
n8{if seq1[i - 1] == seq2[j - 1]}
n9[dp[i][j] = dp[i - 1][j - 1 ...]
n10[dp[i][j] = max(dp[i - 1][...]
n11[]
n12[]
n13[]
n14[return dp[m][n]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n6
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算最長公共子序列長度\n\n Args:\n se...]
n4[(m, n) = (len(seq1), len(seq2...]
n5[dp = [[0] * (n + 1) for _...]
n6{for i in range(1, m + 1)}
n7{for j in range(1, n + 1)}
n8{if seq1[i - 1] == seq2[j - 1]}
n9[dp[i][j] = dp[i - 1][j - 1	...]
n10[dp[i][j] = max(dp[i - 1][...]
n11[]
n12[]
n13[]
n14[return dp[m][n]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n6
n13 --> n14
n14 --> n2
194. core aiva core analysis plan comparator Function match steps
flowchart TB
n1([開始])
n2([結束])
n3['匹配預期步驟與實際執行\n\n Args:\n ex...]
n4[matches: list[StepMatch] = []]
n5[trace_map = {t.step_id: t for t ...]
n6{for step in expected_steps}
n7{if step.step_id in trace_map}
n8[trace = trace_map[step.step_...]
n9[similarity = self._calculate_step...]
n10{if similarity >= 0.9}
n11[match_type = 'exact']
n12{if similarity >= 0.5}
n13[match_type = 'partial']
n14[match_type = 'missing']
n15[]
n16[]
n17[matches.append(StepMatch(expected_step=step, actu...]
n18[matches.append(StepMatch(expected_step=step, actu...]
n19[]
n20[]
n21[expected_step_ids = {s.step_id for s in ...]
n22{for trace in trace_records}
n23{if trace.step_id not in expect...}
n24[matches.append(StepMatch(expected_step=None, actu...]
n25[]
n26[]
n27[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n20
n7 -->|Yes| n8
n7 -->|No| n18
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n19
n18 --> n19
n19 --> n6
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n26
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;匹配預期步驟與實際執行\n\n Args:\n ex...]
n4[matches: list[StepMatch] = []]
n5[trace_map = {t.step_id: t for t ...]
n6{for step in expected_steps}
n7{if step.step_id in trace_map}
n8[trace = trace_map[step.step_...]
n9[similarity = self._calculate_step...]
n10{if similarity &gt;= 0.9}
n11[match_type = &#39;exact&#39;]
n12{if similarity &gt;= 0.5}
n13[match_type = &#39;partial&#39;]
n14[match_type = &#39;missing&#39;]
n15[]
n16[]
n17[matches.append(StepMatch(expected_step=step, actu...]
n18[matches.append(StepMatch(expected_step=step, actu...]
n19[]
n20[]
n21[expected_step_ids = {s.step_id for s in ...]
n22{for trace in trace_records}
n23{if trace.step_id not in expect...}
n24[matches.append(StepMatch(expected_step=None, actu...]
n25[]
n26[]
n27[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n20
n7 -->|Yes| n8
n7 -->|No| n18
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n19
n18 --> n19
n19 --> n6
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n26
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n2
195. core aiva core analysis plan comparator Function compare
flowchart TB
n1([開始])
n2([結束])
n3['對比計畫與執行軌跡\n\n Args:\n plan...]
n4[logger.info(f'Comparing plan {plan.p...]
n5[matches = self._match_steps(pl...]
n6[expected_steps = len(plan.steps)]
n7[executed_steps = len(trace_records)]
n8[completed_steps = sum((1 for t in trac...]
n9[failed_steps = sum((1 for t in trac...]
n10[skipped_steps = sum((1 for t in trac...]
n11[extra_actions = self._count_extra_ac...]
n12[completion_rate = completed_steps / ex...]
n13[success_rate = completed_steps / ex...]
n14[sequence_accuracy = self._calculate_sequ...]
n15[goal_achieved = self._evaluate_goal_...]
n16[reward_score = self._calculate_rewa...]
n17[total_execution_time = sum((t.execution_tim...]
n18[metrics = PlanExecutionMetrics...]
n19[logger.info(f'Comparison complete: comple...]
n20[return metrics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;對比計畫與執行軌跡\n\n Args:\n plan...]
n4[logger.info(f&#39;Comparing plan {plan.p...]
n5[matches = self._match_steps(pl...]
n6[expected_steps = len(plan.steps)]
n7[executed_steps = len(trace_records)]
n8[completed_steps = sum((1 for t in trac...]
n9[failed_steps = sum((1 for t in trac...]
n10[skipped_steps = sum((1 for t in trac...]
n11[extra_actions = self._count_extra_ac...]
n12[completion_rate = completed_steps / ex...]
n13[success_rate = completed_steps / ex...]
n14[sequence_accuracy = self._calculate_sequ...]
n15[goal_achieved = self._evaluate_goal_...]
n16[reward_score = self._calculate_rewa...]
n17[total_execution_time = sum((t.execution_tim...]
n18[metrics = PlanExecutionMetrics...]
n19[logger.info(f&#39;Comparison complete: comple...]
n20[return metrics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
196. core aiva core analysis plan comparator Function generate comparison report
flowchart TB
n1([開始])
n2([結束])
n3['生成詳細的對比分析報告\n\n Args:\n pl...]
n4[matches = self._match_steps(pl...]
n5[report: dict[str, Any] = {'plan_...]
n6{for match in matches}
n7[step_info: dict[str, Any] = {'ma...]
n8{if match.expected_step}
n9[step_info['expected'] = &...]
n10[]
n11{if match.actual_trace}
n12[step_info['actual'] = ...]
n13[]
n14[report['step_analysis'].a...]
n15[]
n16[report['recommendations']...]
n17[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n15
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n6
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成詳細的對比分析報告\n\n Args:\n pl...]
n4[matches = self._match_steps(pl...]
n5[report: dict[str, Any] = {&#39;plan_...]
n6{for match in matches}
n7[step_info: dict[str, Any] = {&#39;ma...]
n8{if match.expected_step}
n9[step_info[&#39;expected&#39;] = &...]
n10[]
n11{if match.actual_trace}
n12[step_info[&#39;actual&#39;] = ...]
n13[]
n14[report[&#39;step_analysis&#39;].a...]
n15[]
n16[report[&#39;recommendations&#39;]...]
n17[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n15
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n6
n15 --> n16
n16 --> n17
n17 --> n2
197. core aiva core analysis risk assessment engine Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化風險評估引擎\n\n Args:\n ...]
n4[self.enable_threat_intel = enable_threat_intel]
n5[self.intel_aggregator: IntelAggregator | None = No...]
n6{if enable_threat_intel}
n7[try]
n8[from services.integration.aiva_integration.threat_...]
n9[self.intel_aggregator = IntelAggregator()]
n10[logger.info('Threat intelligence enabled ...]
n11[]
n12[except ImportError]
n13[logger.warning('Threat intel module not a...]
n14[self.enable_threat_intel = False]
n15[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n15
n7 --> n8
n7 --> n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n15
n12 --> n13
n13 --> n14
n14 --> n11
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化風險評估引擎\n\n Args:\n ...]
n4[self.enable_threat_intel = enable_threat_intel]
n5[self.intel_aggregator: IntelAggregator | None = No...]
n6{if enable_threat_intel}
n7[try]
n8[from services.integration.aiva_integration.threat_...]
n9[self.intel_aggregator = IntelAggregator()]
n10[logger.info(&#39;Threat intelligence enabled ...]
n11[]
n12[except ImportError]
n13[logger.warning(&#39;Threat intel module not a...]
n14[self.enable_threat_intel = False]
n15[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n15
n7 --> n8
n7 --> n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n15
n12 --> n13
n13 --> n14
n14 --> n11
n15 --> n2
198. core aiva core analysis risk assessment engine Function adjust by asset criticality
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據資產重要性調整分數\n\n Args:\n ...]
n4[url = str(finding.target.u...]
n5[critical_paths = ['/admin', &...]
n6[high_paths = ['/api', &...]
n7{if any((path in url.lower() fo...}
n8[base_score *= 1.3]
n9{if any((path in url.lower() fo...}
n10[base_score *= 1.15]
n11[]
n12[]
n13[return base_score]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據資產重要性調整分數\n\n Args:\n ...]
n4[url = str(finding.target.u...]
n5[critical_paths = [&#39;/admin&#39;, &...]
n6[high_paths = [&#39;/api&#39;, &&#...]
n7{if any((path in url.lower() fo...}
n8[base_score *= 1.3]
n9{if any((path in url.lower() fo...}
n10[base_score *= 1.15]
n11[]
n12[]
n13[return base_score]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
199. core aiva core analysis risk assessment engine Function adjust by exploitability
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據可利用性調整分數\n\n Args:\n ...]
n4{if finding.evidence and findin...}
n5[base_score *= 1.1]
n6[]
n7[confidence_multipliers = {'Certain&&...]
n8[multiplier = confidence_multiplie...]
n9[base_score *= multiplier]
n10[return base_score]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據可利用性調整分數\n\n Args:\n ...]
n4{if finding.evidence and findin...}
n5[base_score *= 1.1]
n6[]
n7[confidence_multipliers = {&#39;Certain&&...]
n8[multiplier = confidence_multiplie...]
n9[base_score *= multiplier]
n10[return base_score]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
200. core aiva core analysis risk assessment engine Function calculate base score
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算基礎 CVSS 分數\n\n Args:\n ...]
n4[severity_scores = {Severity.CRITICAL: ...]
n5[base_score = severity_scores.get(...]
n6[vuln_type_multipliers = {VulnerabilityType.S...]
n7[multiplier = vuln_type_multiplier...]
n8[base_score *= multiplier]
n9[return base_score]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算基礎 CVSS 分數\n\n Args:\n ...]
n4[severity_scores = {Severity.CRITICAL: ...]
n5[base_score = severity_scores.get(...]
n6[vuln_type_multipliers = {VulnerabilityType.S...]
n7[multiplier = vuln_type_multiplier...]
n8[base_score *= multiplier]
n9[return base_score]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
201. core aiva core analysis risk assessment engine Function get risk level
flowchart TB
n1([開始])
n2([結束])
n3['\n 將風險分數轉換為威脅等級\n\n Args:\n ...]
n4{if risk_score >= 9.0}
n5[return ThreatLevel.CRITICAL]
n6{if risk_score >= 7.0}
n7[return ThreatLevel.HIGH]
n8{if risk_score >= 4.0}
n9[return ThreatLevel.MEDIUM]
n10{if risk_score >= 2.0}
n11[return ThreatLevel.LOW]
n12[return ThreatLevel.INFO]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將風險分數轉換為威脅等級\n\n Args:\n ...]
n4{if risk_score &gt;= 9.0}
n5[return ThreatLevel.CRITICAL]
n6{if risk_score &gt;= 7.0}
n7[return ThreatLevel.HIGH]
n8{if risk_score &gt;= 4.0}
n9[return ThreatLevel.MEDIUM]
n10{if risk_score &gt;= 2.0}
n11[return ThreatLevel.LOW]
n12[return ThreatLevel.INFO]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
202. core aiva core analysis strategy generator Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化策略生成器\n\n Args:\n ...]
n4[self.config = config or StrategyGe...]
n5[logger.info('[目標] RuleBasedStrate...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化策略生成器\n\n Args:\n ...]
n4[self.config = config or StrategyGe...]
n5[logger.info(&#39;[目標] RuleBasedStrate...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
203. core aiva core analysis strategy generator Function calculate priority
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算任務優先級\n\n Args:\n ...]
n4[base_priority = {'high_risk'...]
n5{if confidence >= self.config.h...}
n6[base_priority = min(base_priority + ...]
n7{if confidence >= 0.5}
n8[base_priority = min(base_priority + ...]
n9[]
n10[]
n11[return base_priority]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算任務優先級\n\n Args:\n ...]
n4[base_priority = {&#39;high_risk&#39;...]
n5{if confidence &gt;= self.config.h...}
n6[base_priority = min(base_priority + ...]
n7{if confidence &gt;= 0.5}
n8[base_priority = min(base_priority + ...]
n9[]
n10[]
n11[return base_priority]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
204. core aiva core analysis strategy generator Function estimate duration
flowchart TB
n1([開始])
n2([結束])
n3['\n 預估總執行時間(秒)\n\n Args:\n ...]
n4[total = xss_count * self.con...]
n5[concurrent_factor = 5]
n6[return total // concurrent_factor]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 預估總執行時間(秒)\n\n Args:\n ...]
n4[total = xss_count * self.con...]
n5[concurrent_factor = 5]
n6[return total // concurrent_factor]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
205. core aiva core analysis strategy generator Function generate idor tasks
flowchart TB
n1([開始])
n2([結束])
n3['生成 IDOR 測試任務']
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence < self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 IDOR 測試任務&#39;]
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence &lt; self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
206. core aiva core analysis strategy generator Function generate sqli tasks
flowchart TB
n1([開始])
n2([結束])
n3['生成 SQLi 測試任務']
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence < self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 SQLi 測試任務&#39;]
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence &lt; self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
207. core aiva core analysis strategy generator Function generate ssrf tasks
flowchart TB
n1([開始])
n2([結束])
n3['生成 SSRF 測試任務']
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence < self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 SSRF 測試任務&#39;]
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence &lt; self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
208. core aiva core analysis strategy generator Function generate xss tasks
flowchart TB
n1([開始])
n2([結束])
n3['生成 XSS 測試任務']
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence < self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 XSS 測試任務&#39;]
n4[tasks = []]
n5{for candidate in candidates}
n6{if candidate.confidence &lt; self...}
n7[continue]
n8[]
n9[priority = self._calculate_prio...]
n10[task = TestTask(vulnerabili...]
n11[tasks.append(task)]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
209. core aiva core analysis strategy generator Function prioritize tasks
flowchart TB
n1([開始])
n2([結束])
n3['\n 按優先級和置信度排序任務,保留最重要的部分\n\n A...]
n4[sorted_tasks = sorted(tasks, key=la...]
n5[limit = self.config.max_task...]
n6[return sorted_tasks[:limit]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 按優先級和置信度排序任務,保留最重要的部分\n\n A...]
n4[sorted_tasks = sorted(tasks, key=la...]
n5[limit = self.config.max_task...]
n6[return sorted_tasks[:limit]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
210. core aiva core analysis strategy generator Function generate
flowchart TB
n1([開始])
n2([結束])
n3['\n 從攻擊面分析生成測試策略\n\n Args:\n ...]
n4[logger.info(f'[目標] Generating tes...]
n5[logger.info(f' - Total candidates: ...]
n6[xss_tasks = self._generate_xss_t...]
n7[sqli_tasks = self._generate_sqli_...]
n8[ssrf_tasks = self._generate_ssrf_...]
n9[idor_tasks = self._generate_idor_...]
n10[total_tasks = len(xss_tasks) + len...]
n11{if total_tasks > self.config.m...}
n12[logger.warning(f'[警告] Total task...]
n13[xss_tasks = self._prioritize_tas...]
n14[sqli_tasks = self._prioritize_tas...]
n15[ssrf_tasks = self._prioritize_tas...]
n16[idor_tasks = self._prioritize_tas...]
n17[]
n18[estimated_duration = self._estimate_durat...]
n19[strategy = TestStrategy(scan_id...]
n20[logger.info(f'[已] Strategy genera...]
n21[return strategy]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n17
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 從攻擊面分析生成測試策略\n\n Args:\n ...]
n4[logger.info(f&#39;[目標] Generating tes...]
n5[logger.info(f&#39; - Total candidates: ...]
n6[xss_tasks = self._generate_xss_t...]
n7[sqli_tasks = self._generate_sqli_...]
n8[ssrf_tasks = self._generate_ssrf_...]
n9[idor_tasks = self._generate_idor_...]
n10[total_tasks = len(xss_tasks) + len...]
n11{if total_tasks &gt; self.config.m...}
n12[logger.warning(f&#39;[警告] Total task...]
n13[xss_tasks = self._prioritize_tas...]
n14[sqli_tasks = self._prioritize_tas...]
n15[ssrf_tasks = self._prioritize_tas...]
n16[idor_tasks = self._prioritize_tas...]
n17[]
n18[estimated_duration = self._estimate_durat...]
n19[strategy = TestStrategy(scan_id...]
n20[logger.info(f&#39;[已] Strategy genera...]
n21[return strategy]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n17
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
211. core aiva core app Function count tasks by type
flowchart TB
n1([開始])
n2([結束])
n3['統計各類型任務的數量']
n4[return dict(Counter((topic.value for ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;統計各類型任務的數量&#39;]
n4[return dict(Counter((topic.value for ...]
n1 --> n3
n3 --> n4
n4 --> n2
212. core aiva core authz authz mapper Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化權限映射器\n\n Args:\n ...]
n4[self.matrix = permission_matrix]
n5[self.user_roles: dict[str, list[str]] = &...]
n6[self.user_attributes: dict[str, dict[str, Any]...]
n7[logger.info('authz_mapper_initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化權限映射器\n\n Args:\n ...]
n4[self.matrix = permission_matrix]
n5[self.user_roles: dict[str, list[str]] = &...]
n6[self.user_attributes: dict[str, dict[str, Any]...]
n7[logger.info(&#39;authz_mapper_initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
213. core aiva core authz authz mapper Function analyze role overlap
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析角色重疊情況\n\n Returns:\n ...]
n4[overlaps = []]
n5[roles = list(self.matrix.rol...]
n6{for (i, role1) in enumerate(roles)}
n7{for role2 in roles[i + 1:]}
n8[role1_perms = {(p['resource&...]
n9[role2_perms = {(p['resource&...]
n10[common_perms = role1_perms & role2_...]
n11{if common_perms}
n12[overlap_ratio = len(common_perms) / ...]
n13[overlaps.append({'role1'...]
n14[]
n15[]
n16[]
n17[logger.info('role_overlap_analyzed&...]
n18[return overlaps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n15
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n7
n15 --> n6
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析角色重疊情況\n\n Returns:\n ...]
n4[overlaps = []]
n5[roles = list(self.matrix.rol...]
n6{for (i, role1) in enumerate(roles)}
n7{for role2 in roles[i + 1:]}
n8[role1_perms = {(p[&#39;resource&...]
n9[role2_perms = {(p[&#39;resource&...]
n10[common_perms = role1_perms & role2_...]
n11{if common_perms}
n12[overlap_ratio = len(common_perms) / ...]
n13[overlaps.append({&#39;role1&#39;...]
n14[]
n15[]
n16[]
n17[logger.info(&#39;role_overlap_analyzed&&#...]
n18[return overlaps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n15
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n7
n15 --> n6
n16 --> n17
n17 --> n18
n18 --> n2
214. core aiva core authz authz mapper Function assign role to user
flowchart TB
n1([開始])
n2([結束])
n3['\n 分配角色給用戶\n\n Args:\n ...]
n4{if user_id not in self.user_roles}
n5[self.user_roles[user_id] = []]
n6[]
n7{if role not in self.user_roles...}
n8[self.user_roles[user_id].append(role)]
n9[logger.info('role_assigned_to_user&...]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分配角色給用戶\n\n Args:\n ...]
n4{if user_id not in self.user_roles}
n5[self.user_roles[user_id] = []]
n6[]
n7{if role not in self.user_roles...}
n8[self.user_roles[user_id].append(role)]
n9[logger.info(&#39;role_assigned_to_user&&#...]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n2
215. core aiva core authz authz mapper Function check user permission
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查用戶權限\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5{if not user_roles}
n6[logger.debug('user_has_no_roles&#...]
n7[return (AccessDecision.DENY, [])]
n8[]
n9[full_context = context or {}]
n10{if user_id in self.user_attrib...}
n11[full_context.update(self.user_attributes[user_id&...]
n12[]
n13[full_context['user_id'] =...]
n14[decisions: list[tuple[AccessDecision, str] ...]
n15{for role in user_roles}
n16[decision = self.matrix.check_pe...]
n17[decisions.append((decision, role))]
n18[]
n19[allow_roles = [role for dec, role ...]
n20{if allow_roles}
n21[logger.info('user_permission_granted&...]
n22[return (AccessDecision.ALLOW, allow_r...]
n23[]
n24[conditional_roles = [role for dec, role ...]
n25{if conditional_roles}
n26[logger.info('user_permission_conditional&...]
n27[return (AccessDecision.CONDITIONAL, c...]
n28[]
n29[logger.info('user_permission_denied&&...]
n30[return (AccessDecision.DENY, [])]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n23
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n28
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查用戶權限\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5{if not user_roles}
n6[logger.debug(&#39;user_has_no_roles&#...]
n7[return (AccessDecision.DENY, [])]
n8[]
n9[full_context = context or {}]
n10{if user_id in self.user_attrib...}
n11[full_context.update(self.user_attributes[user_id&...]
n12[]
n13[full_context[&#39;user_id&#39;] =...]
n14[decisions: list[tuple[AccessDecision, str]	...]
n15{for role in user_roles}
n16[decision = self.matrix.check_pe...]
n17[decisions.append((decision, role))]
n18[]
n19[allow_roles = [role for dec, role ...]
n20{if allow_roles}
n21[logger.info(&#39;user_permission_granted&...]
n22[return (AccessDecision.ALLOW, allow_r...]
n23[]
n24[conditional_roles = [role for dec, role ...]
n25{if conditional_roles}
n26[logger.info(&#39;user_permission_conditional&...]
n27[return (AccessDecision.CONDITIONAL, c...]
n28[]
n29[logger.info(&#39;user_permission_denied&&...]
n30[return (AccessDecision.DENY, [])]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n23
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n28
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
216. core aiva core authz authz mapper Function detect permission conflicts
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測用戶的權限衝突\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5[conflicts = []]
n6[permission_map: dict[tuple[str, str], list ...]
n7{for role in user_roles}
n8[role_permissions = self.matrix.get_role...]
n9{for perm in role_permissions}
n10[key = (perm['resource' ...]
n11{if key not in permission_map}
n12[permission_map[key] = []]
n13[]
n14[permission_map[key].append((role, perm ...]
n15[]
n16[]
n17{for ((resource, permission), role_decisions...}
n18{if len(role_decisions) > 1}
n19[decisions = [dec for _, dec in r...]
n20{if AccessDecision.ALLOW in dec...}
n21[conflicts.append({'resource&#...]
n22[]
n23[]
n24[]
n25[logger.info('permission_conflicts_detecte...]
n26[return conflicts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n16
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n15
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n9
n15 --> n7
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n24
n18 -->|Yes| n19
n18 -->|No| n23
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n17
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測用戶的權限衝突\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5[conflicts = []]
n6[permission_map: dict[tuple[str, str], list	...]
n7{for role in user_roles}
n8[role_permissions = self.matrix.get_role...]
n9{for perm in role_permissions}
n10[key = (perm[&#39;resource&#39;	...]
n11{if key not in permission_map}
n12[permission_map[key] = []]
n13[]
n14[permission_map[key].append((role, perm	...]
n15[]
n16[]
n17{for ((resource, permission), role_decisions&#...}
n18{if len(role_decisions) &gt; 1}
n19[decisions = [dec for _, dec in r...]
n20{if AccessDecision.ALLOW in dec...}
n21[conflicts.append({&#39;resource&#...]
n22[]
n23[]
n24[]
n25[logger.info(&#39;permission_conflicts_detecte...]
n26[return conflicts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n16
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n15
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n9
n15 --> n7
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n24
n18 -->|Yes| n19
n18 -->|No| n23
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n17
n24 --> n25
n25 --> n26
n26 --> n2
217. core aiva core authz authz mapper Function get user all permissions
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取用戶的所有權限\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5[all_permissions = []]
n6{for role in user_roles}
n7[role_permissions = self.matrix.get_role...]
n8{for perm in role_permissions}
n9[all_permissions.append({**perm, 'via...]
n10[]
n11[]
n12[logger.debug('user_all_permissions_retrie...]
n13[return all_permissions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n6
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取用戶的所有權限\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5[all_permissions = []]
n6{for role in user_roles}
n7[role_permissions = self.matrix.get_role...]
n8{for perm in role_permissions}
n9[all_permissions.append({**perm, &#39;via...]
n10[]
n11[]
n12[logger.debug(&#39;user_all_permissions_retrie...]
n13[return all_permissions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n6
n11 --> n12
n12 --> n13
n13 --> n2
218. core aiva core authz authz mapper Function get user roles
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取用戶的所有角色\n\n Args:\n ...]
n4[return self.user_roles.get(user_id, [...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取用戶的所有角色\n\n Args:\n ...]
n4[return self.user_roles.get(user_id, [...]
n1 --> n3
n3 --> n4
n4 --> n2
219. core aiva core authz authz mapper Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[from .permission_matrix import PermissionMatrix]
n5[matrix = PermissionMatrix()]
n6[matrix.grant_permission('admin...]
n7[matrix.grant_permission('admin...]
n8[matrix.grant_permission('admin...]
n9[matrix.grant_permission('user'...]
n10[matrix.grant_permission('user'...]
n11[matrix.grant_permission('user'...]
n12[matrix.grant_permission('guest...]
n13[mapper = AuthZMapper(matrix)]
n14[mapper.assign_role_to_user('alice&...]
n15[mapper.assign_role_to_user('bob&#...]
n16[mapper.assign_role_to_user('bob&#...]
n17[mapper.set_user_attribute('bob...]
n18[print('=== Permission Checks ===&#...]
n19[(decision, roles) = mapper.check_user_pe...]
n20[print(f'Alice delete database: {deci...]
n21[(decision, roles) = mapper.check_user_pe...]
n22[print(f'Bob write database: {decisio...]
n23[print('\n=== Conflicts ===')]
n24[conflicts = mapper.detect_permis...]
n25{for conflict in conflicts}
n26[print(f'Conflict: {conflict}&am...]
n27[]
n28[print('\n=== Role Removal Simulation ===&...]
n29[impact = mapper.simulate_role...]
n30[print(f'Impact: {impact}&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n25
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[from .permission_matrix import PermissionMatrix]
n5[matrix = PermissionMatrix()]
n6[matrix.grant_permission(&#39;admin&#3...]
n7[matrix.grant_permission(&#39;admin&#3...]
n8[matrix.grant_permission(&#39;admin&#3...]
n9[matrix.grant_permission(&#39;user&#39...]
n10[matrix.grant_permission(&#39;user&#39...]
n11[matrix.grant_permission(&#39;user&#39...]
n12[matrix.grant_permission(&#39;guest&#3...]
n13[mapper = AuthZMapper(matrix)]
n14[mapper.assign_role_to_user(&#39;alice&...]
n15[mapper.assign_role_to_user(&#39;bob&#...]
n16[mapper.assign_role_to_user(&#39;bob&#...]
n17[mapper.set_user_attribute(&#39;bob&#3...]
n18[print(&#39;=== Permission Checks ===&#...]
n19[(decision, roles) = mapper.check_user_pe...]
n20[print(f&#39;Alice delete database: {deci...]
n21[(decision, roles) = mapper.check_user_pe...]
n22[print(f&#39;Bob write database: {decisio...]
n23[print(&#39;\n=== Conflicts ===&#39;)]
n24[conflicts = mapper.detect_permis...]
n25{for conflict in conflicts}
n26[print(f&#39;Conflict: {conflict}&am...]
n27[]
n28[print(&#39;\n=== Role Removal Simulation ===&...]
n29[impact = mapper.simulate_role...]
n30[print(f&#39;Impact: {impact}&&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n25
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
220. core aiva core authz authz mapper Function recommend role consolidation
flowchart TB
n1([開始])
n2([結束])
n3['\n 推薦角色整合\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5{if len(user_roles) <= 1}
n6[return []]
n7[]
n8[recommendations = []]
n9[overlaps = []]
n10{for (i, role1) in enumerate(user_ro...}
n11{for role2 in user_roles[i + 1:]}
n12[role1_perms = self.matrix.get_role...]
n13[role2_perms = self.matrix.get_role...]
n14[role1_set = {(p['resource&...]
n15[role2_set = {(p['resource&...]
n16[overlap = role1_set & role2_se...]
n17{if overlap}
n18[overlap_ratio = len(overlap) / min(l...]
n19[overlaps.append({'role1'...]
n20[]
n21[]
n22[]
n23{for overlap in overlaps}
n24{if overlap['overlap_ratio' ...}
n25[recommendations.append({'type&...]
n26[]
n27[]
n28[logger.info('role_consolidation_recommend...]
n29[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n22
n11 -->|Yes| n12
n11 -->|No| n21
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n11
n21 --> n10
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n27
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n23
n27 --> n28
n28 --> n29
n29 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 推薦角色整合\n\n Args:\n ...]
n4[user_roles = self.get_user_roles(...]
n5{if len(user_roles) &lt;= 1}
n6[return []]
n7[]
n8[recommendations = []]
n9[overlaps = []]
n10{for (i, role1) in enumerate(user_ro...}
n11{for role2 in user_roles[i + 1:]}
n12[role1_perms = self.matrix.get_role...]
n13[role2_perms = self.matrix.get_role...]
n14[role1_set = {(p[&#39;resource&&#...]
n15[role2_set = {(p[&#39;resource&&#...]
n16[overlap = role1_set & role2_se...]
n17{if overlap}
n18[overlap_ratio = len(overlap) / min(l...]
n19[overlaps.append({&#39;role1&#39;...]
n20[]
n21[]
n22[]
n23{for overlap in overlaps}
n24{if overlap[&#39;overlap_ratio&#39;	...}
n25[recommendations.append({&#39;type&&#...]
n26[]
n27[]
n28[logger.info(&#39;role_consolidation_recommend...]
n29[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n22
n11 -->|Yes| n12
n11 -->|No| n21
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n11
n21 --> n10
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n27
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n23
n27 --> n28
n28 --> n29
n29 --> n2
221. core aiva core authz authz mapper Function revoke role from user
flowchart TB
n1([開始])
n2([結束])
n3['\n 撤銷用戶的角色\n\n Args:\n ...]
n4{if user_id in self.user_roles ...}
n5[self.user_roles[user_id].remove(role)]
n6[logger.info('role_revoked_from_user&&...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 撤銷用戶的角色\n\n Args:\n ...]
n4{if user_id in self.user_roles ...}
n5[self.user_roles[user_id].remove(role)]
n6[logger.info(&#39;role_revoked_from_user&&...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
222. core aiva core authz authz mapper Function set user attribute
flowchart TB
n1([開始])
n2([結束])
n3['\n 設置用戶屬性\n\n Args:\n ...]
n4{if user_id not in self.user_at...}
n5[self.user_attributes[user_id] = {}]
n6[]
n7[self.user_attributes[user_id][attribute] ...]
n8[logger.debug('user_attribute_set&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 設置用戶屬性\n\n Args:\n ...]
n4{if user_id not in self.user_at...}
n5[self.user_attributes[user_id] = {}]
n6[]
n7[self.user_attributes[user_id][attribute] ...]
n8[logger.debug(&#39;user_attribute_set&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
223. core aiva core authz authz mapper Function simulate role removal
flowchart TB
n1([開始])
n2([結束])
n3['\n 模擬移除角色的影響\n\n Args:\n ...]
n4[current_permissions = self.get_user_all_pe...]
n5[current_count = len(current_permissi...]
n6[user_roles = self.user_roles.get(...]
n7{if role not in user_roles}
n8[return {'error': f&#...]
n9[]
n10[temp_roles = [r for r in user_rol...]
n11[original_roles = self.user_roles[user...]
n12[self.user_roles[user_id] = temp_roles]
n13[after_permissions = self.get_user_all_pe...]
n14[after_count = len(after_permission...]
n15[self.user_roles[user_id] = original_roles]
n16[lost_permissions = current_count - afte...]
n17[impact = {'user_id': user_id...]
n18[logger.info('role_removal_simulated&&...]
n19[return impact]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 模擬移除角色的影響\n\n Args:\n ...]
n4[current_permissions = self.get_user_all_pe...]
n5[current_count = len(current_permissi...]
n6[user_roles = self.user_roles.get(...]
n7{if role not in user_roles}
n8[return {&#39;error&#39;: f&#...]
n9[]
n10[temp_roles = [r for r in user_rol...]
n11[original_roles = self.user_roles[user...]
n12[self.user_roles[user_id] = temp_roles]
n13[after_permissions = self.get_user_all_pe...]
n14[after_count = len(after_permission...]
n15[self.user_roles[user_id] = original_roles]
n16[lost_permissions = current_count - afte...]
n17[impact = {&#39;user_id&#39;: user_id...]
n18[logger.info(&#39;role_removal_simulated&&...]
n19[return impact]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
224. core aiva core authz matrix visualizer Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化視覺化器\n\n Args:\n ...]
n4[self.matrix = permission_matrix]
n5[logger.info('matrix_visualizer_initialize...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化視覺化器\n\n Args:\n ...]
n4[self.matrix = permission_matrix]
n5[logger.info(&#39;matrix_visualizer_initialize...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
225. core aiva core authz matrix visualizer Function export to csv
flowchart TB
n1([開始])
n2([結束])
n3['\n 匯出為 CSV\n\n Args:\n ...]
n4[df = self.matrix.to_dataf...]
n5[df.to_csv(output_path, index=False, encoding=&...]
n6[logger.info('matrix_exported_to_csv&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 匯出為 CSV\n\n Args:\n ...]
n4[df = self.matrix.to_dataf...]
n5[df.to_csv(output_path, index=False, encoding=&...]
n6[logger.info(&#39;matrix_exported_to_csv&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
226. core aiva core authz matrix visualizer Function generate coverage chart
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成權限覆蓋率圖表\n\n Returns:\n ...]
n4[analysis = self.matrix.analyze_...]
n5[fig = make_subplots(rows=1...]
n6[stats = analysis['decision_s...]
n7[fig.add_trace(go.Pie(labels=list(stats.keys...]
n8[fig.add_trace(go.Indicator(mode='gaug...]
n9[fig.update_layout(title='Permission Matri...]
n10[logger.info('coverage_chart_generated&...]
n11[return fig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成權限覆蓋率圖表\n\n Returns:\n ...]
n4[analysis = self.matrix.analyze_...]
n5[fig = make_subplots(rows=1...]
n6[stats = analysis[&#39;decision_s...]
n7[fig.add_trace(go.Pie(labels=list(stats.keys&#...]
n8[fig.add_trace(go.Indicator(mode=&#39;gaug...]
n9[fig.update_layout(title=&#39;Permission Matri...]
n10[logger.info(&#39;coverage_chart_generated&...]
n11[return fig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
227. core aiva core authz matrix visualizer Function generate heatmap
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成權限熱力圖\n\n Args:\n ...]
n4[df = self.matrix.to_dataf...]
n5{if df.empty}
n6[logger.warning('cannot_generate_heatmap_e...]
n7[return go.Figure()]
n8[]
n9{if permission_type}
n10[df = df[df['permission'...]
n11[]
n12[pivot_data = []]
n13[roles = sorted(df['role'&...]
n14[resources = sorted(df['resource&&...]
n15{for resource in resources}
n16[row = []]
n17{for role in roles}
n18[mask = (df['role'] ==...]
n19{if mask.any()}
n20[decision = df[mask]['decision&...]
n21{if decision == AccessDecision....}
n22[row.append(2)]
n23{if decision == AccessDecision....}
n24[row.append(1)]
n25[row.append(0)]
n26[]
n27[]
n28[row.append(0)]
n29[]
n30[]
n31[pivot_data.append(row)]
n32[]
n33[fig = go.Figure(data=go.He...]
n34[fig.update_layout(title=f"Permission Matrix ...]
n35[logger.info('heatmap_generated...]
n36[return fig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n32
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n30
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n28
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n27
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n26
n25 --> n26
n26 --> n27
n27 --> n29
n28 --> n29
n29 --> n17
n30 --> n31
n31 --> n15
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成權限熱力圖\n\n Args:\n ...]
n4[df = self.matrix.to_dataf...]
n5{if df.empty}
n6[logger.warning(&#39;cannot_generate_heatmap_e...]
n7[return go.Figure()]
n8[]
n9{if permission_type}
n10[df = df[df[&#39;permission&#39;&#...]
n11[]
n12[pivot_data = []]
n13[roles = sorted(df[&#39;role&#39;&...]
n14[resources = sorted(df[&#39;resource&&...]
n15{for resource in resources}
n16[row = []]
n17{for role in roles}
n18[mask = (df[&#39;role&#39;] ==...]
n19{if mask.any()}
n20[decision = df[mask][&#39;decision&...]
n21{if decision == AccessDecision....}
n22[row.append(2)]
n23{if decision == AccessDecision....}
n24[row.append(1)]
n25[row.append(0)]
n26[]
n27[]
n28[row.append(0)]
n29[]
n30[]
n31[pivot_data.append(row)]
n32[]
n33[fig = go.Figure(data=go.He...]
n34[fig.update_layout(title=f&quot;Permission Matrix ...]
n35[logger.info(&#39;heatmap_generated&#3...]
n36[return fig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n32
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n30
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n28
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n27
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n26
n25 --> n26
n26 --> n27
n27 --> n29
n28 --> n29
n29 --> n17
n30 --> n31
n31 --> n15
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n2
228. core aiva core authz matrix visualizer Function generate html report
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成 HTML 報告\n\n Args:\n ...]
n4[output_path = Path(output_path)]
n5[heatmap = self.generate_heatma...]
n6[coverage = self.generate_covera...]
n7[comparison = self.generate_role_c...]
n8[analysis = self.matrix.analyze_...]
n9[over_privileged = self.matrix.find_ove...]
n10[html_template = '\n<!DOCTYPE html&...]
n11[template = Template(html_templa...]
n12[html_content = template.render(time...]
n13[output_path.write_text(html_content, encoding=&...]
n14[logger.info('html_report_generated&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成 HTML 報告\n\n Args:\n ...]
n4[output_path = Path(output_path)]
n5[heatmap = self.generate_heatma...]
n6[coverage = self.generate_covera...]
n7[comparison = self.generate_role_c...]
n8[analysis = self.matrix.analyze_...]
n9[over_privileged = self.matrix.find_ove...]
n10[html_template = &#39;\n&lt;!DOCTYPE html&...]
n11[template = Template(html_templa...]
n12[html_content = template.render(time...]
n13[output_path.write_text(html_content, encoding=&&#...]
n14[logger.info(&#39;html_report_generated&&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
229. core aiva core authz matrix visualizer Function generate role comparison chart
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成角色權限比較圖表\n\n Returns:\n ...]
n4[df = self.matrix.to_dataf...]
n5{if df.empty}
n6[logger.warning('cannot_generate_compariso...]
n7[return go.Figure()]
n8[]
n9[role_stats = {}]
n10{for role in self.matrix.roles}
n11[perms = self.matrix.get_role...]
n12[role_stats[role] = {'total&&...]
n13[]
n14[roles = list(role_stats.keys...]
n15[fig = go.Figure()]
n16[fig.add_trace(go.Bar(name='Allow&...]
n17[fig.add_trace(go.Bar(name='Conditiona...]
n18[fig.add_trace(go.Bar(name='Deny&&...]
n19[fig.update_layout(title='Role Permission ...]
n20[logger.info('role_comparison_chart_genera...]
n21[return fig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成角色權限比較圖表\n\n Returns:\n ...]
n4[df = self.matrix.to_dataf...]
n5{if df.empty}
n6[logger.warning(&#39;cannot_generate_compariso...]
n7[return go.Figure()]
n8[]
n9[role_stats = {}]
n10{for role in self.matrix.roles}
n11[perms = self.matrix.get_role...]
n12[role_stats[role] = {&#39;total&&...]
n13[]
n14[roles = list(role_stats.keys...]
n15[fig = go.Figure()]
n16[fig.add_trace(go.Bar(name=&#39;Allow&...]
n17[fig.add_trace(go.Bar(name=&#39;Conditiona...]
n18[fig.add_trace(go.Bar(name=&#39;Deny&&...]
n19[fig.update_layout(title=&#39;Role Permission ...]
n20[logger.info(&#39;role_comparison_chart_genera...]
n21[return fig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
230. core aiva core authz matrix visualizer Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[from .permission_matrix import PermissionMatrix]
n5[matrix = PermissionMatrix()]
n6[roles = ['admin', ...]
n7[resources = ['articles', &...]
n8{for role in roles}
n9[matrix.add_role(role)]
n10[]
n11{for resource in resources}
n12[matrix.add_resource(resource)]
n13[]
n14[matrix.grant_permission('admin...]
n15[matrix.grant_permission('admin...]
n16[matrix.grant_permission('admin...]
n17[matrix.grant_permission('editor&#...]
n18[matrix.grant_permission('editor&#...]
n19[matrix.grant_permission('editor&#...]
n20[matrix.grant_permission('editor&#...]
n21[matrix.grant_permission('viewer&#...]
n22[matrix.grant_permission('viewer&#...]
n23[matrix.grant_permission('guest...]
n24[visualizer = MatrixVisualizer(mat...]
n25[visualizer.generate_html_report('permissi...]
n26[print('✅ HTML report generated: permissio...]
n27[visualizer.export_to_csv('permission_matr...]
n28[print('✅ CSV exported: permission_matrix....]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n11
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[from .permission_matrix import PermissionMatrix]
n5[matrix = PermissionMatrix()]
n6[roles = [&#39;admin&#39;, &#3...]
n7[resources = [&#39;articles&#39;, &...]
n8{for role in roles}
n9[matrix.add_role(role)]
n10[]
n11{for resource in resources}
n12[matrix.add_resource(resource)]
n13[]
n14[matrix.grant_permission(&#39;admin&#3...]
n15[matrix.grant_permission(&#39;admin&#3...]
n16[matrix.grant_permission(&#39;admin&#3...]
n17[matrix.grant_permission(&#39;editor&#...]
n18[matrix.grant_permission(&#39;editor&#...]
n19[matrix.grant_permission(&#39;editor&#...]
n20[matrix.grant_permission(&#39;editor&#...]
n21[matrix.grant_permission(&#39;viewer&#...]
n22[matrix.grant_permission(&#39;viewer&#...]
n23[matrix.grant_permission(&#39;guest&#3...]
n24[visualizer = MatrixVisualizer(mat...]
n25[visualizer.generate_html_report(&#39;permissi...]
n26[print(&#39;✅ HTML report generated: permissio...]
n27[visualizer.export_to_csv(&#39;permission_matr...]
n28[print(&#39;✅ CSV exported: permission_matrix....]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n11
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
231. core aiva core authz permission matrix Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化權限矩陣']
n4[self.roles: set[str] = set()]
n5[self.resources: set[str] = set()]
n6[self.permissions: set[str] = set()]
n7[self.matrix: dict[tuple[str, str, str], Acces...]
n8[self.role_inheritance: dict[str, list[str] ...]
n9[self.conditions: dict[tuple[str, str, str], s...]
n10[logger.info('permission_matrix_initialize...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化權限矩陣&#39;]
n4[self.roles: set[str] = set()]
n5[self.resources: set[str] = set()]
n6[self.permissions: set[str] = set()]
n7[self.matrix: dict[tuple[str, str, str], Acces...]
n8[self.role_inheritance: dict[str, list[str]	...]
n9[self.conditions: dict[tuple[str, str, str], s...]
n10[logger.info(&#39;permission_matrix_initialize...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
232. core aiva core authz permission matrix Function evaluate condition
flowchart TB
n1([開始])
n2([結束])
n3['\n 評估條件表達式\n\n Args:\n ...]
n4[try]
n5[return eval(condition, {'__builtins_...]
n6[]
n7[except Exception]
n8[logger.error('condition_evaluation_failed...]
n9[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n7
n5 --> n6
n6 --> n2
n7 --> n8
n8 --> n9
n9 --> n6
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 評估條件表達式\n\n Args:\n ...]
n4[try]
n5[return eval(condition, {&#39;__builtins_...]
n6[]
n7[except Exception]
n8[logger.error(&#39;condition_evaluation_failed...]
n9[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n7
n5 --> n6
n6 --> n2
n7 --> n8
n8 --> n9
n9 --> n6
233. core aiva core authz permission matrix Function add permission
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加權限\n\n Args:\n ...]
n4[self.permissions.add(permission)]
n5[logger.debug('permission_added...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加權限\n\n Args:\n ...]
n4[self.permissions.add(permission)]
n5[logger.debug(&#39;permission_added&#3...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
234. core aiva core authz permission matrix Function add resource
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加資源\n\n Args:\n ...]
n4[self.resources.add(resource)]
n5[logger.debug('resource_added'...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加資源\n\n Args:\n ...]
n4[self.resources.add(resource)]
n5[logger.debug(&#39;resource_added&#39;...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
235. core aiva core authz permission matrix Function add role
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加角色\n\n Args:\n ...]
n4[self.roles.add(role)]
n5{if inherits_from}
n6[self.role_inheritance[role] = inherits_from]
n7[logger.info('role_added_with_inheritance&...]
n8[logger.info('role_added', rol...]
n9[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n9
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加角色\n\n Args:\n ...]
n4[self.roles.add(role)]
n5{if inherits_from}
n6[self.role_inheritance[role] = inherits_from]
n7[logger.info(&#39;role_added_with_inheritance&...]
n8[logger.info(&#39;role_added&#39;, rol...]
n9[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n9
n8 --> n9
n9 --> n2
236. core aiva core authz permission matrix Function analyze coverage
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析權限覆蓋率\n\n Returns:\n ...]
n4[total_possible = len(self.roles) * le...]
n5[total_defined = len(self.matrix)]
n6[coverage = total_defined / tota...]
n7[decision_stats = {AccessDecision.ALLO...]
n8{for decision in self.matrix.values()}
n9[decision_stats[decision] += 1]
n10[]
n11[analysis = {'total_roles': l...]
n12[logger.info('coverage_analyzed...]
n13[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析權限覆蓋率\n\n Returns:\n ...]
n4[total_possible = len(self.roles) * le...]
n5[total_defined = len(self.matrix)]
n6[coverage = total_defined / tota...]
n7[decision_stats = {AccessDecision.ALLO...]
n8{for decision in self.matrix.values()}
n9[decision_stats[decision] += 1]
n10[]
n11[analysis = {&#39;total_roles&#39;: l...]
n12[logger.info(&#39;coverage_analyzed&#3...]
n13[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
237. core aiva core authz permission matrix Function check permission
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查權限\n\n Args:\n ...]
n4[key = (role, resource, per...]
n5{if key in self.matrix}
n6[decision = self.matrix[key]]
n7{if key in self.conditions and ...}
n8[condition = self.conditions[key]]
n9{if self._evaluate_condition(co...}
n10[return decision]
n11[return AccessDecision.DENY]
n12[]
n13[]
n14[return decision]
n15[]
n16{if role in self.role_inheritance}
n17{for parent_role in self.role_inherit...}
n18[parent_decision = self.check_permissio...]
n19{if parent_decision != AccessDe...}
n20[return parent_decision]
n21[]
n22[]
n23[]
n24[return AccessDecision.DENY]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n15
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n13
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n23
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n17
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查權限\n\n Args:\n ...]
n4[key = (role, resource, per...]
n5{if key in self.matrix}
n6[decision = self.matrix[key]]
n7{if key in self.conditions and ...}
n8[condition = self.conditions[key]]
n9{if self._evaluate_condition(co...}
n10[return decision]
n11[return AccessDecision.DENY]
n12[]
n13[]
n14[return decision]
n15[]
n16{if role in self.role_inheritance}
n17{for parent_role in self.role_inherit...}
n18[parent_decision = self.check_permissio...]
n19{if parent_decision != AccessDe...}
n20[return parent_decision]
n21[]
n22[]
n23[]
n24[return AccessDecision.DENY]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n15
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n13
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n23
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n17
n22 --> n23
n23 --> n24
n24 --> n2
238. core aiva core authz permission matrix Function export to dict
flowchart TB
n1([開始])
n2([結束])
n3['\n 匯出為字典格式\n\n Returns:\n ...]
n4[return {'roles': list(se...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 匯出為字典格式\n\n Returns:\n ...]
n4[return {&#39;roles&#39;: list(se...]
n1 --> n3
n3 --> n4
n4 --> n2
239. core aiva core authz permission matrix Function find over privileged roles
flowchart TB
n1([開始])
n2([結束])
n3['\n 查找過度授權的角色\n\n Returns:\n ...]
n4[role_permission_counts = {}]
n5{for role in self.roles}
n6[permissions = self.get_role_permis...]
n7[allow_count = sum((1 for p in perm...]
n8[role_permission_counts[role] = allow_count]
n9[]
n10[counts = list(role_permission...]
n11{if not counts}
n12[return []]
n13[]
n14[mean = np.mean(counts)]
n15[std = np.std(counts)]
n16[threshold = mean + 2 * std]
n17[over_privileged = []]
n18{for (role, count) in role_permission_c...}
n19{if count > threshold}
n20[over_privileged.append({'role&...]
n21[]
n22[]
n23[logger.info('over_privileged_roles_found&...]
n24[return over_privileged]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n22
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n18
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 查找過度授權的角色\n\n Returns:\n ...]
n4[role_permission_counts = {}]
n5{for role in self.roles}
n6[permissions = self.get_role_permis...]
n7[allow_count = sum((1 for p in perm...]
n8[role_permission_counts[role] = allow_count]
n9[]
n10[counts = list(role_permission...]
n11{if not counts}
n12[return []]
n13[]
n14[mean = np.mean(counts)]
n15[std = np.std(counts)]
n16[threshold = mean + 2 * std]
n17[over_privileged = []]
n18{for (role, count) in role_permission_c...}
n19{if count &gt; threshold}
n20[over_privileged.append({&#39;role&&#...]
n21[]
n22[]
n23[logger.info(&#39;over_privileged_roles_found&...]
n24[return over_privileged]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n22
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n18
n22 --> n23
n23 --> n24
n24 --> n2
240. core aiva core authz permission matrix Function get resource permissions
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取資源的所有權限\n\n Args:\n ...]
n4[permissions = []]
n5{for ((role, res, permission), decision) i...}
n6{if res == resource}
n7[permissions.append({'role...]
n8[]
n9[]
n10[logger.debug('resource_permissions_retrie...]
n11[return permissions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取資源的所有權限\n\n Args:\n ...]
n4[permissions = []]
n5{for ((role, res, permission), decision) i...}
n6{if res == resource}
n7[permissions.append({&#39;role&#3...]
n8[]
n9[]
n10[logger.debug(&#39;resource_permissions_retrie...]
n11[return permissions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
241. core aiva core authz permission matrix Function get role permissions
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取角色的所有權限\n\n Args:\n ...]
n4[permissions = []]
n5{for ((r, resource, permission), decision)...}
n6{if r == role}
n7[permissions.append({'resource&...]
n8[]
n9[]
n10[logger.debug('role_permissions_retrieved&...]
n11[return permissions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取角色的所有權限\n\n Args:\n ...]
n4[permissions = []]
n5{for ((r, resource, permission), decision)...}
n6{if r == role}
n7[permissions.append({&#39;resource&&#...]
n8[]
n9[]
n10[logger.debug(&#39;role_permissions_retrieved&...]
n11[return permissions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
242. core aiva core authz permission matrix Function grant permission
flowchart TB
n1([開始])
n2([結束])
n3['\n 授予權限\n\n Args:\n ...]
n4[self.add_role(role)]
n5[self.add_resource(resource)]
n6[self.add_permission(permission)]
n7[key = (role, resource, per...]
n8[self.matrix[key] = decision]
n9{if condition}
n10[self.conditions[key] = condition]
n11[logger.info('permission_granted_with_cond...]
n12[logger.info('permission_granted&#...]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n13
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 授予權限\n\n Args:\n ...]
n4[self.add_role(role)]
n5[self.add_resource(resource)]
n6[self.add_permission(permission)]
n7[key = (role, resource, per...]
n8[self.matrix[key] = decision]
n9{if condition}
n10[self.conditions[key] = condition]
n11[logger.info(&#39;permission_granted_with_cond...]
n12[logger.info(&#39;permission_granted&#...]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n13
n12 --> n13
n13 --> n2
243. core aiva core authz permission matrix Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[matrix = PermissionMatrix()]
n5[matrix.add_role('admin')]
n6[matrix.add_role('user')]
n7[matrix.add_role('guest')]
n8[matrix.add_role('power_user',...]
n9[matrix.grant_permission('admin...]
n10[matrix.grant_permission('admin...]
n11[matrix.grant_permission('admin...]
n12[matrix.grant_permission('user'...]
n13[matrix.grant_permission('user'...]
n14[matrix.grant_permission('guest...]
n15[matrix.grant_permission('guest...]
n16[print('=== Permission Checks ===&#...]
n17[print(f"Admin read database: {matrix.ch...]
n18[print(f"User write database (without con...]
n19[print(f"User write database (with contex...]
n20[print(f"Guest write database: {matrix.c...]
n21[print(f"Power user read database (inheri...]
n22[print('\n=== Coverage Analysis ===&...]
n23[analysis = matrix.analyze_cover...]
n24[print(f"Coverage: {analysis[&...]
n25[print(f"Allow: {analysis[&#...]
n26[print(f"Deny: {analysis[...]
n27[print(f"Conditional: {analysis[&...]
n28[print('\n=== DataFrame ===')]
n29[df = matrix.to_dataframe(...]
n30[print(df)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[matrix = PermissionMatrix()]
n5[matrix.add_role(&#39;admin&#39;)]
n6[matrix.add_role(&#39;user&#39;)]
n7[matrix.add_role(&#39;guest&#39;)]
n8[matrix.add_role(&#39;power_user&#39;,...]
n9[matrix.grant_permission(&#39;admin&#3...]
n10[matrix.grant_permission(&#39;admin&#3...]
n11[matrix.grant_permission(&#39;admin&#3...]
n12[matrix.grant_permission(&#39;user&#39...]
n13[matrix.grant_permission(&#39;user&#39...]
n14[matrix.grant_permission(&#39;guest&#3...]
n15[matrix.grant_permission(&#39;guest&#3...]
n16[print(&#39;=== Permission Checks ===&#...]
n17[print(f&quot;Admin read database: {matrix.ch...]
n18[print(f&quot;User write database (without con...]
n19[print(f&quot;User write database (with contex...]
n20[print(f&quot;Guest write database: {matrix.c...]
n21[print(f&quot;Power user read database (inheri...]
n22[print(&#39;\n=== Coverage Analysis ===&&#...]
n23[analysis = matrix.analyze_cover...]
n24[print(f&quot;Coverage: {analysis[&&#...]
n25[print(f&quot;Allow: {analysis[&#...]
n26[print(f&quot;Deny: {analysis[&#3...]
n27[print(f&quot;Conditional: {analysis[&...]
n28[print(&#39;\n=== DataFrame ===&#39;)]
n29[df = matrix.to_dataframe(...]
n30[print(df)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
244. core aiva core authz permission matrix Function revoke permission
flowchart TB
n1([開始])
n2([結束])
n3['\n 撤銷權限\n\n Args:\n ...]
n4[key = (role, resource, per...]
n5{if key in self.matrix}
n6[del self.matrix[key]]
n7{if key in self.conditions}
n8[del self.conditions[key]]
n9[]
n10[logger.info('permission_revoked&#...]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 撤銷權限\n\n Args:\n ...]
n4[key = (role, resource, per...]
n5{if key in self.matrix}
n6[del self.matrix[key]]
n7{if key in self.conditions}
n8[del self.conditions[key]]
n9[]
n10[logger.info(&#39;permission_revoked&#...]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
245. core aiva core authz permission matrix Function to dataframe
flowchart TB
n1([開始])
n2([結束])
n3['\n 轉換為 Pandas DataFrame\n\n Re...]
n4[data = []]
n5{for ((role, resource, permission), decision...}
n6[has_condition = (role, resource, per...]
n7[data.append({'role': rol...]
n8[]
n9[df = pd.DataFrame(data)]
n10[logger.debug('matrix_converted_to_datafra...]
n11[return df]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 轉換為 Pandas DataFrame\n\n Re...]
n4[data = []]
n5{for ((role, resource, permission), decision&#...}
n6[has_condition = (role, resource, per...]
n7[data.append({&#39;role&#39;: rol...]
n8[]
n9[df = pd.DataFrame(data)]
n10[logger.debug(&#39;matrix_converted_to_datafra...]
n11[return df]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
246. core aiva core authz permission matrix Function to numpy matrix
flowchart TB
n1([開始])
n2([結束])
n3['\n 轉換為 NumPy 矩陣(用於數值分析)\n\n Re...]
n4[roles_list = sorted(self.roles)]
n5[resources_list = sorted(self.resource...]
n6[permissions_list = sorted(self.permissi...]
n7[matrix = np.zeros((len(roles_...]
n8[role_idx = {role: i for i, role...]
n9[resource_idx = {res: i for i, res i...]
n10[permission_idx = {perm: i for i, perm...]
n11{for ((role, resource, permission), decision...}
n12[r_idx = role_idx[role]]
n13[res_idx = resource_idx[resourc...]
n14[p_idx = permission_idx[permi...]
n15{if decision == AccessDecision....}
n16[matrix[r_idx, res_idx, p_idx] = 1]
n17{if decision == AccessDecision....}
n18[matrix[r_idx, res_idx, p_idx] = 2]
n19[]
n20[]
n21[]
n22[logger.debug('matrix_converted_to_numpy&a...]
n23[return (matrix, roles_list, resources...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n21
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n20
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n11
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 轉換為 NumPy 矩陣(用於數值分析)\n\n Re...]
n4[roles_list = sorted(self.roles)]
n5[resources_list = sorted(self.resource...]
n6[permissions_list = sorted(self.permissi...]
n7[matrix = np.zeros((len(roles_...]
n8[role_idx = {role: i for i, role...]
n9[resource_idx = {res: i for i, res i...]
n10[permission_idx = {perm: i for i, perm...]
n11{for ((role, resource, permission), decision&#...}
n12[r_idx = role_idx[role]]
n13[res_idx = resource_idx[resourc...]
n14[p_idx = permission_idx[permi...]
n15{if decision == AccessDecision....}
n16[matrix[r_idx, res_idx, p_idx] = 1]
n17{if decision == AccessDecision....}
n18[matrix[r_idx, res_idx, p_idx] = 2]
n19[]
n20[]
n21[]
n22[logger.debug(&#39;matrix_converted_to_numpy&a...]
n23[return (matrix, roles_list, resources...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n21
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n20
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n11
n21 --> n22
n22 --> n23
n23 --> n2
247. core aiva core bio neuron master Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化主控系統\n\n Args:\n codeba...]
n4[logger.info('🧠 Initializing BioNeuron Mas...]
n5[self.bio_neuron_agent = BioNeuronRAGAgent(co...]
n6[from aiva_core.rag import KnowledgeBase, VectorSto...]
n7[vector_store = VectorStore(backend=...]
n8[knowledge_base = KnowledgeBase(vector...]
n9[self.rag_engine = RAGEngine(knowledge_...]
n10[self.current_mode = default_mode]
n11[self.mode_handlers: dict[OperationMode, Callable]...]
n12[self.conversation = ConversationContext(...]
n13[self.ui_callbacks: dict[str, Callable] = {...]
n14[self.task_queue: list[dict[str, Any]] = &...]
n15[self.active_tasks: dict[str, dict[str, Any]...]
n16[logger.info(f'✅ Master Controller initial...]
n17[logger.info(f' - BioNeuronRAGAgent: ...]
n18[logger.info(f' - RAG Engine: {self...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化主控系統\n\n Args:\n codeba...]
n4[logger.info(&#39;🧠 Initializing BioNeuron Mas...]
n5[self.bio_neuron_agent = BioNeuronRAGAgent(co...]
n6[from aiva_core.rag import KnowledgeBase, VectorSto...]
n7[vector_store = VectorStore(backend=...]
n8[knowledge_base = KnowledgeBase(vector...]
n9[self.rag_engine = RAGEngine(knowledge_...]
n10[self.current_mode = default_mode]
n11[self.mode_handlers: dict[OperationMode, Callable]...]
n12[self.conversation = ConversationContext(...]
n13[self.ui_callbacks: dict[str, Callable] = {&#...]
n14[self.task_queue: list[dict[str, Any]] = &...]
n15[self.active_tasks: dict[str, dict[str, Any]&#...]
n16[logger.info(f&#39;✅ Master Controller initial...]
n17[logger.info(f&#39; - BioNeuronRAGAgent: ...]
n18[logger.info(f&#39; - RAG Engine: {self...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
248. core aiva core bio neuron master Function assess risk
flowchart TB
n1([開始])
n2([結束])
n3['評估風險等級\n\n Args:\n request...]
n4{if isinstance(request, dict)}
n5[action = request.get('action'...]
n6[action = request.lower()]
n7[]
n8[high_risk_keywords = ['刪除', &...]
n9{if any((keyword in action for ...}
n10[return 'high']
n11[]
n12[low_risk_keywords = ['查看', &a...]
n13{if any((keyword in action for ...}
n14[return 'low']
n15[]
n16[return 'medium']
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;評估風險等級\n\n Args:\n request...]
n4{if isinstance(request, dict)}
n5[action = request.get(&#39;action&#39;...]
n6[action = request.lower()]
n7[]
n8[high_risk_keywords = [&#39;刪除&#39;, &...]
n9{if any((keyword in action for ...}
n10[return &#39;high&#39;]
n11[]
n12[low_risk_keywords = [&#39;查看&#39;, &a...]
n13{if any((keyword in action for ...}
n14[return &#39;low&#39;]
n15[]
n16[return &#39;medium&#39;]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n2
249. core aiva core bio neuron master Function format status message
flowchart TB
n1([開始])
n2([結束])
n3['格式化狀態消息\n\n Args:\n status...]
n4[return f"\n當前系統狀態:\n- 操作模式: {status[&am...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;格式化狀態消息\n\n Args:\n status...]
n4[return f&quot;\n當前系統狀態:\n- 操作模式: {status[&am...]
n1 --> n3
n3 --> n4
n4 --> n2
250. core aiva core bio neuron master Function get system status
flowchart TB
n1([開始])
n2([結束])
n3['獲取系統狀態\n\n Returns:\n 狀態信息...]
n4[return {'mode': self.current...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取系統狀態\n\n Returns:\n 狀態信息...]
n4[return {&#39;mode&#39;: self.current...]
n1 --> n3
n3 --> n4
n4 --> n2
251. core aiva core bio neuron master Function record interaction
flowchart TB
n1([開始])
n2([結束])
n3['記錄交互歷史\n\n Args:\n role: 角...]
n4[self.conversation.history.append({'t...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄交互歷史\n\n Args:\n role: 角...]
n4[self.conversation.history.append({&#39;t...]
n1 --> n3
n3 --> n4
n4 --> n2
252. core aiva core bio neuron master Function get conversation history
flowchart TB
n1([開始])
n2([結束])
n3['獲取對話歷史\n\n Args:\n limit: ...]
n4[return self.conversation.history[-lim...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取對話歷史\n\n Args:\n limit: ...]
n4[return self.conversation.history[-lim...]
n1 --> n3
n3 --> n4
n4 --> n2
253. core aiva core bio neuron master Function register ui callback
flowchart TB
n1([開始])
n2([結束])
n3['註冊 UI 回調\n\n Args:\n event...]
n4[self.ui_callbacks[event_type] = callback]
n5[logger.info(f'Registered UI callback: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊 UI 回調\n\n Args:\n event...]
n4[self.ui_callbacks[event_type] = callback]
n5[logger.info(f&#39;Registered UI callback: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
254. core aiva core bio neuron master Function switch mode
flowchart TB
n1([開始])
n2([結束])
n3['切換操作模式\n\n Args:\n mode: 新...]
n4[old_mode = self.current_mode]
n5[self.current_mode = mode]
n6[logger.info(f'Mode switched: {old_mo...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;切換操作模式\n\n Args:\n mode: 新...]
n4[old_mode = self.current_mode]
n5[self.current_mode = mode]
n6[logger.info(f&#39;Mode switched: {old_mo...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
255. core aiva core bizlogic finding helper Function create bizlogic finding
flowchart TB
n1([開始])
n2([結束])
n3['\n 創建業務邏輯漏洞 Finding\n\n Args:\n ...]
n4[vulnerability = Vulnerability(name=v...]
n5[target = FindingTarget(url=ta...]
n6[evidence = FindingEvidence(requ...]
n7[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 創建業務邏輯漏洞 Finding\n\n Args:\n ...]
n4[vulnerability = Vulnerability(name=v...]
n5[target = FindingTarget(url=ta...]
n6[evidence = FindingEvidence(requ...]
n7[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
256. core aiva core business schemas Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
257. core aiva core execution execution status monitor Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._worker_heartbeats: dict[str, datetime] = ...]
n4[self._task_metrics: dict[str, dict[str, Any]&...]
n5[self._system_metrics: dict[str, Any] = {&...]
n6[self._alerts: list[dict[str, Any]] = [...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._worker_heartbeats: dict[str, datetime] = &#...]
n4[self._task_metrics: dict[str, dict[str, Any]&...]
n5[self._system_metrics: dict[str, Any] = {&...]
n6[self._alerts: list[dict[str, Any]] = [...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
258. core aiva core execution execution status monitor Function get recent alerts
flowchart TB
n1([開始])
n2([結束])
n3['獲取最近的警報']
n4[one_hour_ago = datetime.now(UTC) - ...]
n5[recent_alerts = [alert for alert in ...]
n6[return recent_alerts[-10:]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取最近的警報&#39;]
n4[one_hour_ago = datetime.now(UTC) - ...]
n5[recent_alerts = [alert for alert in ...]
n6[return recent_alerts[-10:]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
259. core aiva core execution execution status monitor Function add alert
flowchart TB
n1([開始])
n2([結束])
n3['\n 新增警報\n\n Args:\n ...]
n4[alert = {'timestamp': dateti...]
n5[self._alerts.append(alert)]
n6{if len(self._alerts) > 1000}
n7[self._alerts = self._alerts[-1000:]]
n8[]
n9[logger.warning(f'Alert [{level.u...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 新增警報\n\n Args:\n ...]
n4[alert = {&#39;timestamp&#39;: dateti...]
n5[self._alerts.append(alert)]
n6{if len(self._alerts) &gt; 1000}
n7[self._alerts = self._alerts[-1000:]]
n8[]
n9[logger.warning(f&#39;Alert [{level.u...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
260. core aiva core execution execution status monitor Function check sla violations
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查SLA違規\n\n Returns:\n ...]
n4[violations = []]
n5[now = datetime.now(UTC)]
n6{for (task_id, metric) in self._task_metric...}
n7{if metric['status'] == &a...}
n8[runtime = (now - metric['start...]
n9{if runtime > 600}
n10[violations.append({'task_id&#...]
n11[]
n12[]
n13[]
n14[return violations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查SLA違規\n\n Returns:\n ...]
n4[violations = []]
n5[now = datetime.now(UTC)]
n6{for (task_id, metric) in self._task_metric...}
n7{if metric[&#39;status&#39;] == &a...}
n8[runtime = (now - metric[&#39;start...]
n9{if runtime &gt; 600}
n10[violations.append({&#39;task_id&#...]
n11[]
n12[]
n13[]
n14[return violations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n2
261. core aiva core execution execution status monitor Function get system health
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取系統健康狀態\n\n Returns:\n ...]
n4[now = datetime.now(UTC)]
n5[active_workers = 0]
n6[unhealthy_workers = []]
n7{for (worker_id, last_heartbeat) in self._worker_h...}
n8{if (now - last_heartbeat).tota...}
n9[active_workers += 1]
n10[unhealthy_workers.append({'worker_id...]
n11[]
n12[]
n13[self._system_metrics['active_workers&...]
n14[total_tasks = self._system_metrics...]
n15[failed_tasks = self._system_metrics...]
n16[failure_rate = failed_tasks / max(t...]
n17{if failure_rate > 50}
n18[status = 'critical']
n19{if failure_rate > 20 or active...}
n20[status = 'warning']
n21{if len(unhealthy_workers) > 0}
n22[status = 'degraded']
n23[status = 'healthy']
n24[]
n25[]
n26[]
n27[return {'status': status, &a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n26
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n25
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取系統健康狀態\n\n Returns:\n ...]
n4[now = datetime.now(UTC)]
n5[active_workers = 0]
n6[unhealthy_workers = []]
n7{for (worker_id, last_heartbeat) in self._worker_h...}
n8{if (now - last_heartbeat).tota...}
n9[active_workers += 1]
n10[unhealthy_workers.append({&#39;worker_id...]
n11[]
n12[]
n13[self._system_metrics[&#39;active_workers&...]
n14[total_tasks = self._system_metrics...]
n15[failed_tasks = self._system_metrics...]
n16[failure_rate = failed_tasks / max(t...]
n17{if failure_rate &gt; 50}
n18[status = &#39;critical&#39;]
n19{if failure_rate &gt; 20 or active...}
n20[status = &#39;warning&#39;]
n21{if len(unhealthy_workers) &gt; 0}
n22[status = &#39;degraded&#39;]
n23[status = &#39;healthy&#39;]
n24[]
n25[]
n26[]
n27[return {&#39;status&#39;: status, &a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n26
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n25
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n2
262. core aiva core execution execution status monitor Function record task completion
flowchart TB
n1([開始])
n2([結束])
n3['\n 記錄任務完成\n\n Args:\n ...]
n4{if task_id not in self._task_m...}
n5[return]
n6[]
n7[task_metric = self._task_metrics[t...]
n8[end_time = datetime.now(UTC)]
n9{if not duration_seconds}
n10[duration_seconds = (end_time - task_met...]
n11[]
n12[task_metric.update({'end_time&...]
n13[self._system_metrics['total_tasks_process...]
n14{if not success}
n15[self._system_metrics['failed_tasks&...]
n16[]
n17[total_tasks = self._system_metrics...]
n18[old_avg = self._system_metrics...]
n19[self._system_metrics['avg_task_duration&a...]
n20[status_text = 'success' if succes...]
n21[logger.info(f'Task {task_id} co...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 記錄任務完成\n\n Args:\n ...]
n4{if task_id not in self._task_m...}
n5[return]
n6[]
n7[task_metric = self._task_metrics[t...]
n8[end_time = datetime.now(UTC)]
n9{if not duration_seconds}
n10[duration_seconds = (end_time - task_met...]
n11[]
n12[task_metric.update({&#39;end_time&&#...]
n13[self._system_metrics[&#39;total_tasks_process...]
n14{if not success}
n15[self._system_metrics[&#39;failed_tasks&&#...]
n16[]
n17[total_tasks = self._system_metrics...]
n18[old_avg = self._system_metrics...]
n19[self._system_metrics[&#39;avg_task_duration&a...]
n20[status_text = &#39;success&#39; if succes...]
n21[logger.info(f&#39;Task {task_id} co...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
263. core aiva core execution execution status monitor Function record task start
flowchart TB
n1([開始])
n2([結束])
n3['\n 記錄任務開始執行\n\n Args:\n ...]
n4[self._task_metrics[task_id] = {'...]
n5[logger.info(f'Task {task_id} st...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 記錄任務開始執行\n\n Args:\n ...]
n4[self._task_metrics[task_id] = {&#39;...]
n5[logger.info(f&#39;Task {task_id} st...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
264. core aiva core execution execution status monitor Function record worker heartbeat
flowchart TB
n1([開始])
n2([結束])
n3['\n 記錄Worker心跳\n\n Args:\n ...]
n4[self._worker_heartbeats[worker_id] = datetime.now...]
n5[logger.debug(f'Heartbeat received from wo...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 記錄Worker心跳\n\n Args:\n ...]
n4[self._worker_heartbeats[worker_id] = datetime.now...]
n5[logger.debug(f&#39;Heartbeat received from wo...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
265. core aiva core execution plan executor Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化執行器\n\n Args:\n mq_clie...]
n4[self.mq_client = mq_client]
n5[self.trace_logger = trace_logger or Trac...]
n6[self.storage = storage_backend]
n7[self.active_sessions: dict[str, SessionState] = &...]
n8[logger.info('PlanExecutor initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化執行器\n\n Args:\n mq_clie...]
n4[self.mq_client = mq_client]
n5[self.trace_logger = trace_logger or Trac...]
n6[self.storage = storage_backend]
n7[self.active_sessions: dict[str, SessionState] = &...]
n8[logger.info(&#39;PlanExecutor initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
266. core aiva core execution plan executor Function calculate metrics
flowchart TB
n1([開始])
n2([結束])
n3['計算執行指標\n\n Args:\n plan: 攻...]
n4[expected_steps = len(plan.steps)]
n5[executed_steps = len(trace_records)]
n6[completed_steps = sum((1 for t in trac...]
n7[failed_steps = sum((1 for t in trac...]
n8[skipped_steps = sum((1 for t in trac...]
n9[completion_rate = completed_steps / ex...]
n10[success_rate = completed_steps / ex...]
n11[sequence_accuracy = self._calculate_sequ...]
n12[goal_achieved = completion_rate >= 0...]
n13[reward_score = completion_rate * 0....]
n14[total_execution_time = sum((t.execution_tim...]
n15[return PlanExecutionMetrics(plan_id=p...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算執行指標\n\n Args:\n plan: 攻...]
n4[expected_steps = len(plan.steps)]
n5[executed_steps = len(trace_records)]
n6[completed_steps = sum((1 for t in trac...]
n7[failed_steps = sum((1 for t in trac...]
n8[skipped_steps = sum((1 for t in trac...]
n9[completion_rate = completed_steps / ex...]
n10[success_rate = completed_steps / ex...]
n11[sequence_accuracy = self._calculate_sequ...]
n12[goal_achieved = completion_rate &gt;= 0...]
n13[reward_score = completion_rate * 0....]
n14[total_execution_time = sum((t.execution_tim...]
n15[return PlanExecutionMetrics(plan_id=p...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
267. core aiva core execution plan executor Function calculate sequence accuracy
flowchart TB
n1([開始])
n2([結束])
n3['計算順序準確度\n\n Args:\n plan: ...]
n4{if not trace_records}
n5[return 0.0]
n6[]
n7[expected_order = [step.step_id for st...]
n8[actual_order = [trace.step_id for t...]
n9[matches = sum((1 for i, step_i...]
n10[return matches / len(expected_order) ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算順序準確度\n\n Args:\n plan: ...]
n4{if not trace_records}
n5[return 0.0]
n6[]
n7[expected_order = [step.step_id for st...]
n8[actual_order = [trace.step_id for t...]
n9[matches = sum((1 for i, step_i...]
n10[return matches / len(expected_order) ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
268. core aiva core execution plan executor Function generate recommendations
flowchart TB
n1([開始])
n2([結束])
n3['生成改進建議\n\n Args:\n plan: 攻...]
n4[recommendations = []]
n5{if metrics.success_rate < 0.5}
n6[recommendations.append('成功率過低,建議檢查工具配置和目標...]
n7[]
n8{if metrics.completion_rate < 0.7}
n9[recommendations.append('完成率不足,建議優化步驟依賴和錯誤...]
n10[]
n11{if metrics.sequence_accuracy <...}
n12[recommendations.append('執行順序偏差,建議檢查依賴關係定義...]
n13[]
n14[failed_steps = [t for t in trace_re...]
n15{if len(failed_steps) > 0}
n16[recommendations.append(f'有 {len(...]
n17[]
n18[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成改進建議\n\n Args:\n plan: 攻...]
n4[recommendations = []]
n5{if metrics.success_rate &lt; 0.5}
n6[recommendations.append(&#39;成功率過低,建議檢查工具配置和目標...]
n7[]
n8{if metrics.completion_rate &lt; 0.7}
n9[recommendations.append(&#39;完成率不足,建議優化步驟依賴和錯誤...]
n10[]
n11{if metrics.sequence_accuracy &lt;...}
n12[recommendations.append(&#39;執行順序偏差,建議檢查依賴關係定義...]
n13[]
n14[failed_steps = [t for t in trace_re...]
n15{if len(failed_steps) &gt; 0}
n16[recommendations.append(f&#39;有 {len(...]
n17[]
n18[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
269. core aiva core execution plan executor Function prepare task payload
flowchart TB
n1([開始])
n2([結束])
n3['準備任務 Payload\n\n Args:\n p...]
n4[task_id = f'task_{uuid4().hex ...]
n5[target = FunctionTaskTarget(u...]
n6[payload = FunctionTaskPayload(...]
n7{if not payload.metadata}
n8[payload.metadata = {}]
n9[]
n10[payload.metadata.update({'session_id...]
n11[return payload]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;準備任務 Payload\n\n Args:\n p...]
n4[task_id = f&#39;task_{uuid4().hex	...]
n5[target = FunctionTaskTarget(u...]
n6[payload = FunctionTaskPayload(...]
n7{if not payload.metadata}
n8[payload.metadata = {}]
n9[]
n10[payload.metadata.update({&#39;session_id...]
n11[return payload]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
270. core aiva core execution task generator Function from strategy
flowchart TB
n1([開始])
n2([結束])
n3[tasks: list[tuple[Topic, FunctionTaskPayload]...]
n4{for (index, x) in enumerate(plan.ge...}
n5[tasks.append((Topic.TASK_FUNCTION_XSS, FunctionTa...]
n6[]
n7{for (index, x) in enumerate(plan.ge...}
n8[tasks.append((Topic.TASK_FUNCTION_SQLI, FunctionT...]
n9[]
n10{for (index, x) in enumerate(plan.ge...}
n11[tasks.append((Topic.TASK_FUNCTION_SSRF, FunctionT...]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[tasks: list[tuple[Topic, FunctionTaskPayload]...]
n4{for (index, x) in enumerate(plan.ge...}
n5[tasks.append((Topic.TASK_FUNCTION_XSS, FunctionTa...]
n6[]
n7{for (index, x) in enumerate(plan.ge...}
n8[tasks.append((Topic.TASK_FUNCTION_SQLI, FunctionT...]
n9[]
n10{for (index, x) in enumerate(plan.ge...}
n11[tasks.append((Topic.TASK_FUNCTION_SSRF, FunctionT...]
n12[]
n13[return tasks]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n2
271. core aiva core execution task queue manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._task_queues: dict[str, PriorityQueue] = def...]
n4[self._task_status: dict[str, dict[str, Any]...]
n5[self._scan_stats: dict[str, dict[str, int] ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._task_queues: dict[str, PriorityQueue] = def...]
n4[self._task_status: dict[str, dict[str, Any]&#...]
n5[self._scan_stats: dict[str, dict[str, int]	...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
272. core aiva core execution task queue manager Function enqueue task
flowchart TB
n1([開始])
n2([結束])
n3['\n 將任務加入佇列\n\n Args:\n ...]
n4[scan_id = task_payload.scan_id]
n5[task_id = task_payload.task_id]
n6[priority = task_payload.priorit...]
n7[queue_item = (-priority, datetime...]
n8[self._task_queues[scan_id].put(queue_item)]
n9[self._task_status[task_id] = {'s...]
n10[self._scan_stats[scan_id]['total&...]
n11[self._scan_stats[scan_id]['pendin...]
n12[logger.info(f'Enqueued task {task_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將任務加入佇列\n\n Args:\n ...]
n4[scan_id = task_payload.scan_id]
n5[task_id = task_payload.task_id]
n6[priority = task_payload.priorit...]
n7[queue_item = (-priority, datetime...]
n8[self._task_queues[scan_id].put(queue_item)]
n9[self._task_status[task_id] = {&#39;s...]
n10[self._scan_stats[scan_id][&#39;total&...]
n11[self._scan_stats[scan_id][&#39;pendin...]
n12[logger.info(f&#39;Enqueued task {task_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
273. core aiva core execution task queue manager Function get pending tasks
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取待執行任務列表\n\n Args:\n ...]
n4[pending_tasks = []]
n5{for (task_id, task_info) in self._task_status...}
n6{if task_info['scan_id'] =...}
n7[pending_tasks.append({'task_id&&...]
n8[]
n9[]
n10[pending_tasks.sort(key=lambda x: x['p...]
n11[return pending_tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取待執行任務列表\n\n Args:\n ...]
n4[pending_tasks = []]
n5{for (task_id, task_info) in self._task_status...}
n6{if task_info[&#39;scan_id&#39;] =...}
n7[pending_tasks.append({&#39;task_id&&...]
n8[]
n9[]
n10[pending_tasks.sort(key=lambda x: x[&#39;p...]
n11[return pending_tasks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
274. core aiva core execution task queue manager Function get queue status
flowchart TB
n1([開始])
n2([結束])
n3['獲取佇列整體狀態']
n4[total_scans = len(self._scan_stats...]
n5[total_tasks = sum((stats['total&a...]
n6[pending_tasks = sum((stats['pendi...]
n7[running_tasks = sum((stats['runni...]
n8[return {'total_scans': total...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取佇列整體狀態&#39;]
n4[total_scans = len(self._scan_stats...]
n5[total_tasks = sum((stats[&#39;total&a...]
n6[pending_tasks = sum((stats[&#39;pendi...]
n7[running_tasks = sum((stats[&#39;runni...]
n8[return {&#39;total_scans&#39;: total...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
275. core aiva core execution task queue manager Function mark task completed
flowchart TB
n1([開始])
n2([結束])
n3['標記任務為完成']
n4{if task_id in self._task_status}
n5[task_info = self._task_status[ta...]
n6[old_status = task_info['status...]
n7[task_info['status'] = &am...]
n8[task_info['completed_at']...]
n9{if result}
n10[task_info['result'] = result]
n11[]
n12[scan_id = task_info['scan_id'...]
n13{if old_status == 'running'}
n14[self._scan_stats[scan_id]['runnin...]
n15[self._scan_stats[scan_id]['comple...]
n16[]
n17[logger.info(f'Task {task_id} co...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n18
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;標記任務為完成&#39;]
n4{if task_id in self._task_status}
n5[task_info = self._task_status[ta...]
n6[old_status = task_info[&#39;status&#3...]
n7[task_info[&#39;status&#39;] = &am...]
n8[task_info[&#39;completed_at&#39;]...]
n9{if result}
n10[task_info[&#39;result&#39;] = result]
n11[]
n12[scan_id = task_info[&#39;scan_id&#39;...]
n13{if old_status == &#39;running&#39;}
n14[self._scan_stats[scan_id][&#39;runnin...]
n15[self._scan_stats[scan_id][&#39;comple...]
n16[]
n17[logger.info(f&#39;Task {task_id} co...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n18
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
276. core aiva core execution task queue manager Function mark task failed
flowchart TB
n1([開始])
n2([結束])
n3['標記任務為失敗']
n4{if task_id in self._task_status}
n5[task_info = self._task_status[ta...]
n6[old_status = task_info['status...]
n7[task_info['status'] = &am...]
n8[task_info['failed_at'] = ...]
n9[task_info['error'] = error]
n10[scan_id = task_info['scan_id'...]
n11{if old_status in ['pending', ...}
n12[self._scan_stats[scan_id][old_status] -= 1]
n13[self._scan_stats[scan_id]['failed...]
n14[]
n15[logger.warning(f'Task {task_id}...]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n16
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;標記任務為失敗&#39;]
n4{if task_id in self._task_status}
n5[task_info = self._task_status[ta...]
n6[old_status = task_info[&#39;status&#3...]
n7[task_info[&#39;status&#39;] = &am...]
n8[task_info[&#39;failed_at&#39;] = ...]
n9[task_info[&#39;error&#39;] = error]
n10[scan_id = task_info[&#39;scan_id&#39;...]
n11{if old_status in [&#39;pending&#39;, ...}
n12[self._scan_stats[scan_id][old_status] -= 1]
n13[self._scan_stats[scan_id][&#39;failed...]
n14[]
n15[logger.warning(f&#39;Task {task_id}...]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n16
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
277. core aiva core execution task queue manager Function mark task running
flowchart TB
n1([開始])
n2([結束])
n3['標記任務為執行中']
n4{if task_id in self._task_status}
n5[task_info = self._task_status[ta...]
n6[old_status = task_info['status...]
n7[task_info['status'] = &am...]
n8[task_info['started_at'] =...]
n9[scan_id = task_info['scan_id'...]
n10{if old_status == 'pending'}
n11[self._scan_stats[scan_id]['pendin...]
n12[self._scan_stats[scan_id]['runnin...]
n13[]
n14[logger.info(f'Task {task_id} is...]
n15[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n15
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;標記任務為執行中&#39;]
n4{if task_id in self._task_status}
n5[task_info = self._task_status[ta...]
n6[old_status = task_info[&#39;status&#3...]
n7[task_info[&#39;status&#39;] = &am...]
n8[task_info[&#39;started_at&#39;] =...]
n9[scan_id = task_info[&#39;scan_id&#39;...]
n10{if old_status == &#39;pending&#39;}
n11[self._scan_stats[scan_id][&#39;pendin...]
n12[self._scan_stats[scan_id][&#39;runnin...]
n13[]
n14[logger.info(f&#39;Task {task_id} is...]
n15[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n15
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
278. core aiva core execution task queue manager Function update task queue
flowchart TB
n1([開始])
n2([結束])
n3['\n 更新任務佇列\n\n Args:\n ...]
n4[task_count = len(updated_tasks)]
n5[logger.info(f'Task queue update requested...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 更新任務佇列\n\n Args:\n ...]
n4[task_count = len(updated_tasks)]
n5[logger.info(f&#39;Task queue update requested...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
279. core aiva core execution trace logger Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化追蹤記錄器\n\n Args:\n stora...]
n4[self.storage = storage_backend]
n5[self.active_sessions: dict[str, SessionState] = &...]
n6[logger.info('TraceLogger initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化追蹤記錄器\n\n Args:\n stora...]
n4[self.storage = storage_backend]
n5[self.active_sessions: dict[str, SessionState] = &...]
n6[logger.info(&#39;TraceLogger initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
280. core aiva core execution trace logger Function update session state
flowchart TB
n1([開始])
n2([結束])
n3['更新會話狀態\n\n Args:\n session...]
n4{if session_id not in self.acti...}
n5[logger.warning(f'Session {session_id...]
n6[return]
n7[]
n8[session = self.active_sessions...]
n9{if status == 'success' and ste...}
n10[session.completed_steps.append(step_id)]
n11[]
n12{if step_id in session.pending_...}
n13[session.pending_steps.remove(step_id)]
n14[]
n15[session.current_step_index += 1]
n16[session.updated_at = datetime.now(UTC)]
n17[logger.debug(f'Updated session {sess...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新會話狀態\n\n Args:\n session...]
n4{if session_id not in self.acti...}
n5[logger.warning(f&#39;Session {session_id...]
n6[return]
n7[]
n8[session = self.active_sessions...]
n9{if status == &#39;success&#39; and ste...}
n10[session.completed_steps.append(step_id)]
n11[]
n12{if step_id in session.pending_...}
n13[session.pending_steps.remove(step_id)]
n14[]
n15[session.current_step_index += 1]
n16[session.updated_at = datetime.now(UTC)]
n17[logger.debug(f&#39;Updated session {sess...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
281. core aiva core execution trace logger Function abort session
flowchart TB
n1([開始])
n2([結束])
n3['中止會話\n\n Args:\n session_i...]
n4[self.update_session_status(session_id, 'a...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;中止會話\n\n Args:\n session_i...]
n4[self.update_session_status(session_id, &#39;a...]
n1 --> n3
n3 --> n4
n4 --> n2
282. core aiva core execution trace logger Function complete session
flowchart TB
n1([開始])
n2([結束])
n3['完成會話\n\n Args:\n session_i...]
n4[self.update_session_status(session_id, 'c...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;完成會話\n\n Args:\n session_i...]
n4[self.update_session_status(session_id, &#39;c...]
n1 --> n3
n3 --> n4
n4 --> n2
283. core aiva core execution trace logger Function create session
flowchart TB
n1([開始])
n2([結束])
n3['創建新的會話\n\n Args:\n plan_id...]
n4[session_id = f'session_{uuid4()....]
n5[timeout_at = datetime.now(UTC)]
n6[timeout_at = timeout_at.replace(m...]
n7[session = SessionState(session...]
n8[self.active_sessions[session_id] = session]
n9[logger.info(f'Created session {sessi...]
n10[return session]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建新的會話\n\n Args:\n plan_id...]
n4[session_id = f&#39;session_{uuid4()....]
n5[timeout_at = datetime.now(UTC)]
n6[timeout_at = timeout_at.replace(m...]
n7[session = SessionState(session...]
n8[self.active_sessions[session_id] = session]
n9[logger.info(f&#39;Created session {sessi...]
n10[return session]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
284. core aiva core execution trace logger Function create trace record
flowchart TB
n1([開始])
n2([結束])
n3['創建追蹤記錄\n\n Args:\n plan_id...]
n4[trace_id = f'trace_{uuid4().hex...]
n5[trace = TraceRecord(trace_id...]
n6[logger.info(f'Created trace record {...]
n7[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建追蹤記錄\n\n Args:\n plan_id...]
n4[trace_id = f&#39;trace_{uuid4().hex...]
n5[trace = TraceRecord(trace_id...]
n6[logger.info(f&#39;Created trace record {...]
n7[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
285. core aiva core execution trace logger Function fail session
flowchart TB
n1([開始])
n2([結束])
n3['標記會話為失敗\n\n Args:\n sessio...]
n4[self.update_session_status(session_id, 'f...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;標記會話為失敗\n\n Args:\n sessio...]
n4[self.update_session_status(session_id, &#39;f...]
n1 --> n3
n3 --> n4
n4 --> n2
286. core aiva core execution trace logger Function get session
flowchart TB
n1([開始])
n2([結束])
n3['獲取會話狀態\n\n Args:\n session...]
n4[return self.active_sessions.get(sessi...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取會話狀態\n\n Args:\n session...]
n4[return self.active_sessions.get(sessi...]
n1 --> n3
n3 --> n4
n4 --> n2
287. core aiva core execution trace logger Function update session status
flowchart TB
n1([開始])
n2([結束])
n3['更新會話狀態\n\n Args:\n session...]
n4{if session_id in self.active_s...}
n5[self.active_sessions[session_id].status = status]
n6[self.active_sessions[session_id].updated_at = dat...]
n7[logger.info(f'Updated session {sessi...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新會話狀態\n\n Args:\n session...]
n4{if session_id in self.active_s...}
n5[self.active_sessions[session_id].status = status]
n6[self.active_sessions[session_id].updated_at = dat...]
n7[logger.info(f&#39;Updated session {sessi...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
288. core aiva core execution tracer execution monitor Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化監控器\n\n Args:\n trace_r...]
n4[self.trace_recorder = trace_recorder or Tr...]
n5[self.active_contexts: dict[str, ExecutionContext]...]
n6[logger.info('ExecutionMonitor initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化監控器\n\n Args:\n trace_r...]
n4[self.trace_recorder = trace_recorder or Tr...]
n5[self.active_contexts: dict[str, ExecutionContext]...]
n6[logger.info(&#39;ExecutionMonitor initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
289. core aiva core execution tracer execution monitor Function complete task execution
flowchart TB
n1([開始])
n2([結束])
n3['完成任務執行\n\n Args:\n context...]
n4[self.trace_recorder.record_task_end(trace_session_...]
n5{if context.task_id in self.act...}
n6[del self.active_contexts[context.task_id]]
n7[]
n8[status = 'successfully' if su...]
n9[logger.info(f'Task {context.task_id&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;完成任務執行\n\n Args:\n context...]
n4[self.trace_recorder.record_task_end(trace_session_...]
n5{if context.task_id in self.act...}
n6[del self.active_contexts[context.task_id]]
n7[]
n8[status = &#39;successfully&#39; if su...]
n9[logger.info(f&#39;Task {context.task_id&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
290. core aiva core execution tracer execution monitor Function finalize monitoring
flowchart TB
n1([開始])
n2([結束])
n3['結束監控\n\n Args:\n trace_ses...]
n4[trace = self.trace_recorder....]
n5{if trace}
n6[logger.info(f'Monitoring completed for se...]
n7[]
n8[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;結束監控\n\n Args:\n trace_ses...]
n4[trace = self.trace_recorder....]
n5{if trace}
n6[logger.info(f&#39;Monitoring completed for se...]
n7[]
n8[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
291. core aiva core execution tracer execution monitor Function get active tasks
flowchart TB
n1([開始])
n2([結束])
n3['獲取正在執行的任務列表']
n4[return list(self.active_contexts.keys...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取正在執行的任務列表&#39;]
n4[return list(self.active_contexts.keys...]
n1 --> n3
n3 --> n4
n4 --> n2
292. core aiva core execution tracer execution monitor Function get trace summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取軌跡摘要\n\n Args:\n trace_s...]
n4[trace = self.trace_recorder....]
n5{if not trace}
n6[return None]
n7[]
n8[type_counts = {}]
n9{for entry in trace.entries}
n10[trace_type = entry.trace_type.val...]
n11[type_counts[trace_type] = type_counts.get(tra...]
n12[]
n13[duration = None]
n14{if trace.end_time}
n15[duration = (trace.end_time - tr...]
n16[]
n17[return {'trace_session_id': ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取軌跡摘要\n\n Args:\n trace_s...]
n4[trace = self.trace_recorder....]
n5{if not trace}
n6[return None]
n7[]
n8[type_counts = {}]
n9{for entry in trace.entries}
n10[trace_type = entry.trace_type.val...]
n11[type_counts[trace_type] = type_counts.get(tra...]
n12[]
n13[duration = None]
n14{if trace.end_time}
n15[duration = (trace.end_time - tr...]
n16[]
n17[return {&#39;trace_session_id&#39;: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
293. core aiva core execution tracer execution monitor Function record decision point
flowchart TB
n1([開始])
n2([結束])
n3['記錄決策點\n\n Args:\n context:...]
n4[content = {'decision_type': ...]
n5[self.trace_recorder.record(trace_session_id=contex...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄決策點\n\n Args:\n context:...]
n4[content = {&#39;decision_type&#39;: ...]
n5[self.trace_recorder.record(trace_session_id=contex...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
294. core aiva core execution tracer execution monitor Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤\n\n Args:\n context: ...]
n4[self.trace_recorder.record_error(trace_session_id=...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤\n\n Args:\n context: ...]
n4[self.trace_recorder.record_error(trace_session_id=...]
n1 --> n3
n3 --> n4
n4 --> n2
295. core aiva core execution tracer execution monitor Function record step
flowchart TB
n1([開始])
n2([結束])
n3['記錄執行步驟\n\n Args:\n context...]
n4[content = {'step': step_name...]
n5[self.trace_recorder.record(trace_session_id=contex...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄執行步驟\n\n Args:\n context...]
n4[content = {&#39;step&#39;: step_name...]
n5[self.trace_recorder.record(trace_session_id=contex...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
296. core aiva core execution tracer execution monitor Function record tool invocation
flowchart TB
n1([開始])
n2([結束])
n3['記錄工具調用\n\n Args:\n context...]
n4[content = {'tool': tool_name...]
n5[self.trace_recorder.record(trace_session_id=contex...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄工具調用\n\n Args:\n context...]
n4[content = {&#39;tool&#39;: tool_name...]
n5[self.trace_recorder.record(trace_session_id=contex...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
297. core aiva core execution tracer execution monitor Function start monitoring
flowchart TB
n1([開始])
n2([結束])
n3['開始監控執行計畫\n\n Args:\n plan:...]
n4[trace_metadata = {'plan_id':...]
n5[trace = self.trace_recorder....]
n6[logger.info(f'Started monitoring plan ...]
n7[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;開始監控執行計畫\n\n Args:\n plan:...]
n4[trace_metadata = {&#39;plan_id&#39;:...]
n5[trace = self.trace_recorder....]
n6[logger.info(f&#39;Started monitoring plan ...]
n7[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
298. core aiva core execution tracer execution monitor Function start task execution
flowchart TB
n1([開始])
n2([結束])
n3['開始執行任務\n\n Args:\n trace_s...]
n4[context = ExecutionContext(pla...]
n5[self.active_contexts[task.task_id] = context]
n6[task_info = {'task_id': task...]
n7[self.trace_recorder.record_task_start(trace_sessio...]
n8[logger.info(f'Started task execution: ...]
n9[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;開始執行任務\n\n Args:\n trace_s...]
n4[context = ExecutionContext(pla...]
n5[self.active_contexts[task.task_id] = context]
n6[task_info = {&#39;task_id&#39;: task...]
n7[self.trace_recorder.record_task_start(trace_sessio...]
n8[logger.info(f&#39;Started task execution: ...]
n9[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
299. core aiva core execution tracer task executor Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化執行器\n\n Args:\n executi...]
n4[self.monitor = execution_monitor or...]
n5[logger.info('TaskExecutor initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化執行器\n\n Args:\n executi...]
n4[self.monitor = execution_monitor or...]
n5[logger.info(&#39;TaskExecutor initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
300. core aiva core execution tracer trace recorder Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化記錄器']
n4[self.active_traces: dict[str, ExecutionTrace] = &...]
n5[logger.info('TraceRecorder initialized&am...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化記錄器&#39;]
n4[self.active_traces: dict[str, ExecutionTrace] = &...]
n5[logger.info(&#39;TraceRecorder initialized&am...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
301. core aiva core execution tracer trace recorder Function add entry
flowchart TB
n1([開始])
n2([結束])
n3['添加軌跡條目']
n4[self.entries.append(entry)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加軌跡條目&#39;]
n4[self.entries.append(entry)]
n1 --> n3
n3 --> n4
n4 --> n2
302. core aiva core execution tracer trace recorder Function finalize trace
flowchart TB
n1([開始])
n2([結束])
n3['結束軌跡記錄\n\n Args:\n trace_s...]
n4[trace = self.active_traces.g...]
n5{if trace}
n6[trace.finalize()]
n7[logger.info(f'Finalized trace session ...]
n8[return trace]
n9[]
n10[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;結束軌跡記錄\n\n Args:\n trace_s...]
n4[trace = self.active_traces.g...]
n5{if trace}
n6[trace.finalize()]
n7[logger.info(f&#39;Finalized trace session ...]
n8[return trace]
n9[]
n10[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
303. core aiva core execution tracer trace recorder Function finalize
flowchart TB
n1([開始])
n2([結束])
n3['結束軌跡記錄']
n4[self.end_time = datetime.now()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;結束軌跡記錄&#39;]
n4[self.end_time = datetime.now()]
n1 --> n3
n3 --> n4
n4 --> n2
304. core aiva core execution tracer trace recorder Function get entries by task
flowchart TB
n1([開始])
n2([結束])
n3['獲取特定任務的所有軌跡']
n4[return [e for e in self.entries if e....]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取特定任務的所有軌跡&#39;]
n4[return [e for e in self.entries if e....]
n1 --> n3
n3 --> n4
n4 --> n2
305. core aiva core execution tracer trace recorder Function get entries by type
flowchart TB
n1([開始])
n2([結束])
n3['獲取特定類型的所有軌跡']
n4[return [e for e in self.entries if e....]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取特定類型的所有軌跡&#39;]
n4[return [e for e in self.entries if e....]
n1 --> n3
n3 --> n4
n4 --> n2
306. core aiva core execution tracer trace recorder Function get trace
flowchart TB
n1([開始])
n2([結束])
n3['獲取軌跡']
n4[return self.active_traces.get(trace_s...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取軌跡&#39;]
n4[return self.active_traces.get(trace_s...]
n1 --> n3
n3 --> n4
n4 --> n2
307. core aiva core execution tracer trace recorder Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤']
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤&#39;]
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
308. core aiva core execution tracer trace recorder Function record http request
flowchart TB
n1([開始])
n2([結束])
n3['記錄 HTTP 請求']
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 HTTP 請求&#39;]
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
309. core aiva core execution tracer trace recorder Function record http response
flowchart TB
n1([開始])
n2([結束])
n3['記錄 HTTP 回應']
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 HTTP 回應&#39;]
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
310. core aiva core execution tracer trace recorder Function record log
flowchart TB
n1([開始])
n2([結束])
n3['記錄日誌']
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄日誌&#39;]
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
311. core aiva core execution tracer trace recorder Function record task end
flowchart TB
n1([開始])
n2([結束])
n3['記錄任務結束']
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄任務結束&#39;]
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
312. core aiva core execution tracer trace recorder Function record task start
flowchart TB
n1([開始])
n2([結束])
n3['記錄任務開始']
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄任務開始&#39;]
n4[self.record(trace_session_id=trace_session_id, tra...]
n1 --> n3
n3 --> n4
n4 --> n2
313. core aiva core execution tracer trace recorder Function record
flowchart TB
n1([開始])
n2([結束])
n3['記錄一條軌跡\n\n Args:\n trace_s...]
n4[trace = self.active_traces.g...]
n5{if not trace}
n6[logger.warning(f'Trace session {trac...]
n7[return None]
n8[]
n9[entry = TraceEntry(trace_id=...]
n10[trace.add_entry(entry)]
n11[logger.debug(f'Recorded {trace_type....]
n12[return entry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄一條軌跡\n\n Args:\n trace_s...]
n4[trace = self.active_traces.g...]
n5{if not trace}
n6[logger.warning(f&#39;Trace session {trac...]
n7[return None]
n8[]
n9[entry = TraceEntry(trace_id=...]
n10[trace.add_entry(entry)]
n11[logger.debug(f&#39;Recorded {trace_type....]
n12[return entry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
314. core aiva core execution tracer trace recorder Function start trace
flowchart TB
n1([開始])
n2([結束])
n3['開始一個新的軌跡記錄\n\n Args:\n pla...]
n4[trace_session_id = f'trace_{uuid4(...]
n5[trace = ExecutionTrace(trace...]
n6[self.active_traces[trace_session_id] = trace]
n7[logger.info(f'Started trace session {...]
n8[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;開始一個新的軌跡記錄\n\n Args:\n pla...]
n4[trace_session_id = f&#39;trace_{uuid4(&#...]
n5[trace = ExecutionTrace(trace...]
n6[self.active_traces[trace_session_id] = trace]
n7[logger.info(f&#39;Started trace session {...]
n8[return trace]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
315. core aiva core execution tracer trace recorder Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典']
n4[return {'trace_session_id': ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典&#39;]
n4[return {&#39;trace_session_id&#39;: ...]
n1 --> n3
n3 --> n4
n4 --> n2
316. core aiva core execution tracer trace recorder Function to json
flowchart TB
n1([開始])
n2([結束])
n3['轉換為 JSON 字串']
n4[return json.dumps(self.to_dict(), ens...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為 JSON 字串&#39;]
n4[return json.dumps(self.to_dict(), ens...]
n1 --> n3
n3 --> n4
n4 --> n2
317. core aiva core learning experience manager Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化經驗管理器\n\n Args:\n stora...]
n4[self.storage = storage_backend]
n5[logger.info('ExperienceManager initialize...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化經驗管理器\n\n Args:\n stora...]
n4[self.storage = storage_backend]
n5[logger.info(&#39;ExperienceManager initialize...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
318. core aiva core learning experience manager Function auto label
flowchart TB
n1([開始])
n2([結束])
n3['自動標註樣本\n\n Args:\n metrics...]
n4{if metrics.goal_achieved and m...}
n5[return 'success']
n6{if metrics.completion_rate >= ...}
n7[return 'partial_success']
n8[return 'failure']
n9[]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;自動標註樣本\n\n Args:\n metrics...]
n4{if metrics.goal_achieved and m...}
n5[return &#39;success&#39;]
n6{if metrics.completion_rate &gt;= ...}
n7[return &#39;partial_success&#39;]
n8[return &#39;failure&#39;]
n9[]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n2
319. core aiva core learning experience manager Function calculate quality score
flowchart TB
n1([開始])
n2([結束])
n3['計算樣本質量分數\n\n Args:\n resul...]
n4[factors = []]
n5[completion_factor = result.metrics.compl...]
n6[factors.append(completion_factor * 0.3)]
n7[trace_completeness = min(sum((1 for t in ...]
n8[factors.append(trace_completeness * 0.3)]
n9[result_clarity = 1.0 if result.metric...]
n10[factors.append(result_clarity * 0.2)]
n11[anomaly_factor = 1.0 - min(len(result...]
n12[factors.append(anomaly_factor * 0.2)]
n13[return sum(factors)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算樣本質量分數\n\n Args:\n resul...]
n4[factors = []]
n5[completion_factor = result.metrics.compl...]
n6[factors.append(completion_factor * 0.3)]
n7[trace_completeness = min(sum((1 for t in ...]
n8[factors.append(trace_completeness * 0.3)]
n9[result_clarity = 1.0 if result.metric...]
n10[factors.append(result_clarity * 0.2)]
n11[anomaly_factor = 1.0 - min(len(result...]
n12[factors.append(anomaly_factor * 0.2)]
n13[return sum(factors)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
320. core aiva core learning experience manager Function extract context
flowchart TB
n1([開始])
n2([結束])
n3['提取場景上下文\n\n Args:\n plan: ...]
n4[return {'attack_type': plan....]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取場景上下文\n\n Args:\n plan: ...]
n4[return {&#39;attack_type&#39;: plan....]
n1 --> n3
n3 --> n4
n4 --> n2
321. core aiva core learning model trainer Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化訓練器\n\n Args:\n model_d...]
n4[self.model_dir = model_dir or Path('....]
n5[self.model_dir.mkdir(parents=True, exist_ok=True)]
n6[self.storage = storage_backend]
n7[self.current_model: Any | None = None]
n8[self.model_version = 'v0.0.0']
n9[logger.info(f'ModelTrainer initialized wi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化訓練器\n\n Args:\n model_d...]
n4[self.model_dir = model_dir or Path(&#39;....]
n5[self.model_dir.mkdir(parents=True, exist_ok=True)]
n6[self.storage = storage_backend]
n7[self.current_model: Any | None = None]
n8[self.model_version = &#39;v0.0.0&#39;]
n9[logger.info(f&#39;ModelTrainer initialized wi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
322. core aiva core learning model trainer Function build state vector
flowchart TB
n1([開始])
n2([結束])
n3['構建狀態向量\n\n Args:\n sample:...]
n4[state = []]
n5[attack_type = sample.context.get('...]
n6[state.extend(self._encode_attack_type(attack_type...]
n7[progress = step_index / max(len...]
n8[state.append(progress)]
n9[completed = sum((1 for t in samp...]
n10[state.append(completed / max(len(sample.plan....]
n11[return np.array(state, dtype=np.float...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建狀態向量\n\n Args:\n sample:...]
n4[state = []]
n5[attack_type = sample.context.get(&#39;...]
n6[state.extend(self._encode_attack_type(attack_type...]
n7[progress = step_index / max(len...]
n8[state.append(progress)]
n9[completed = sum((1 for t in samp...]
n10[state.append(completed / max(len(sample.plan....]
n11[return np.array(state, dtype=np.float...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
323. core aiva core learning model trainer Function calculate step reward
flowchart TB
n1([開始])
n2([結束])
n3['計算步驟獎勵\n\n Args:\n trace: ...]
n4[reward = 0.0]
n5{if trace.status == 'success'}
n6[reward += 1.0]
n7{if trace.status == 'failed'}
n8[reward -= 0.5]
n9[]
n10[]
n11{if step_index < len(sample.pla...}
n12[expected_step = sample.plan.steps[st...]
n13{if expected_step.step_id == tr...}
n14[reward += 0.5]
n15[]
n16[]
n17{if trace.output_data.get('find...}
n18[reward += 2.0]
n19[]
n20{if trace.execution_time_second...}
n21[reward -= 0.2]
n22[]
n23[return reward]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算步驟獎勵\n\n Args:\n trace: ...]
n4[reward = 0.0]
n5{if trace.status == &#39;success&#39;}
n6[reward += 1.0]
n7{if trace.status == &#39;failed&#39;}
n8[reward -= 0.5]
n9[]
n10[]
n11{if step_index &lt; len(sample.pla...}
n12[expected_step = sample.plan.steps[st...]
n13{if expected_step.step_id == tr...}
n14[reward += 0.5]
n15[]
n16[]
n17{if trace.output_data.get(&#39;find...}
n18[reward += 2.0]
n19[]
n20{if trace.execution_time_second...}
n21[reward -= 0.2]
n22[]
n23[return reward]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n2
324. core aiva core learning model trainer Function encode action
flowchart TB
n1([開始])
n2([結束])
n3['編碼動作\n\n Args:\n trace: 追蹤...]
n4[tool_map = {'function_sqli':...]
n5[return tool_map.get(trace.tool_name, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;編碼動作\n\n Args:\n trace: 追蹤...]
n4[tool_map = {&#39;function_sqli&#39;:...]
n5[return tool_map.get(trace.tool_name, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
325. core aiva core learning model trainer Function encode attack type
flowchart TB
n1([開始])
n2([結束])
n3['編碼攻擊類型\n\n Args:\n attack_...]
n4[types = ['SQLI', '...]
n5[return [1.0 if t == attack_type else ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;編碼攻擊類型\n\n Args:\n attack_...]
n4[types = [&#39;SQLI&#39;, &#39...]
n5[return [1.0 if t == attack_type else ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
326. core aiva core learning model trainer Function extract features
flowchart TB
n1([開始])
n2([結束])
n3['從樣本中提取特徵向量\n\n Args:\n sam...]
n4[features: list[float] = []]
n5[attack_types = ['SQLI', &...]
n6[attack_type = sample.context.get('...]
n7[attack_one_hot = [1.0 if t == attack_...]
n8[features.extend(attack_one_hot)]
n9[features.append(float(len(sample.plan.steps...]
n10[features.append(float(len(sample.plan.depende...]
n11[metrics = sample.metrics]
n12[features.extend([metrics.completion_rate, metrics...]
n13[target_info = sample.context.get('...]
n14[features.append(1.0 if target_info.get(&#...]
n15[features.append(len(target_info.get(&#...]
n16[return np.array(features, dtype=np.fl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從樣本中提取特徵向量\n\n Args:\n sam...]
n4[features: list[float] = []]
n5[attack_types = [&#39;SQLI&#39;, &...]
n6[attack_type = sample.context.get(&#39;...]
n7[attack_one_hot = [1.0 if t == attack_...]
n8[features.extend(attack_one_hot)]
n9[features.append(float(len(sample.plan.steps&#...]
n10[features.append(float(len(sample.plan.depende...]
n11[metrics = sample.metrics]
n12[features.extend([metrics.completion_rate, metrics...]
n13[target_info = sample.context.get(&#39;...]
n14[features.append(1.0 if target_info.get(&#...]
n15[features.append(len(target_info.get(&#...]
n16[return np.array(features, dtype=np.fl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
327. core aiva core learning model trainer Function increment version
flowchart TB
n1([開始])
n2([結束])
n3['遞增版本號\n\n Args:\n current_...]
n4[parts = current_version.lstr...]
n5[(major, minor, patch) = map(int, parts)]
n6[patch += 1]
n7[return f'v{major}.{minor}...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;遞增版本號\n\n Args:\n current_...]
n4[parts = current_version.lstr...]
n5[(major, minor, patch) = map(int, parts)]
n6[patch += 1]
n7[return f&#39;v{major}.{minor}...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
328. core aiva core learning model trainer Function prepare rl data
flowchart TB
n1([開始])
n2([結束])
n3['準備強化學習數據(episode 格式)\n\n Args:\n ...]
n4[episodes = []]
n5{for sample in samples}
n6[states = []]
n7[actions = []]
n8[rewards = []]
n9{for (i, trace) in enumerate(sample....}
n10[state = self._build_state_ve...]
n11[states.append(state)]
n12[action = self._encode_action(...]
n13[actions.append(action)]
n14[reward = self._calculate_step...]
n15[rewards.append(reward)]
n16[]
n17[episode = {'states': np.arra...]
n18[episodes.append(episode)]
n19[]
n20[return episodes]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n19
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n9
n16 --> n17
n17 --> n18
n18 --> n5
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;準備強化學習數據(episode 格式)\n\n Args:\n ...]
n4[episodes = []]
n5{for sample in samples}
n6[states = []]
n7[actions = []]
n8[rewards = []]
n9{for (i, trace) in enumerate(sample....}
n10[state = self._build_state_ve...]
n11[states.append(state)]
n12[action = self._encode_action(...]
n13[actions.append(action)]
n14[reward = self._calculate_step...]
n15[rewards.append(reward)]
n16[]
n17[episode = {&#39;states&#39;: np.arra...]
n18[episodes.append(episode)]
n19[]
n20[return episodes]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n19
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n9
n16 --> n17
n17 --> n18
n18 --> n5
n19 --> n20
n20 --> n2
329. core aiva core learning model trainer Function prepare supervised data
flowchart TB
n1([開始])
n2([結束])
n3['準備監督學習數據\n\n Args:\n sampl...]
n4[X = []]
n5[y = []]
n6{for sample in samples}
n7[features = self._extract_featur...]
n8[X.append(features)]
n9[label = 1 if sample.label ==...]
n10[y.append(label)]
n11[]
n12[X = np.array(X)]
n13[y = np.array(y)]
n14[split_idx = int(len(X) * (1 - va...]
n15[indices = np.random.permutatio...]
n16[X = X[indices]]
n17[y = y[indices]]
n18[(X_train, X_val) = (X[:split_idx], X&...]
n19[(y_train, y_val) = (y[:split_idx], y&...]
n20[return (X_train, y_train, X_val, y_va...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;準備監督學習數據\n\n Args:\n sampl...]
n4[X = []]
n5[y = []]
n6{for sample in samples}
n7[features = self._extract_featur...]
n8[X.append(features)]
n9[label = 1 if sample.label ==...]
n10[y.append(label)]
n11[]
n12[X = np.array(X)]
n13[y = np.array(y)]
n14[split_idx = int(len(X) * (1 - va...]
n15[indices = np.random.permutatio...]
n16[X = X[indices]]
n17[y = y[indices]]
n18[(X_train, X_val) = (X[:split_idx], X&...]
n19[(y_train, y_val) = (y[:split_idx], y&...]
n20[return (X_train, y_train, X_val, y_va...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
330. core aiva core multilang coordinator Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化多語言 AI 協調器']
n4[logger.info('🌐 初始化多語言 AI 協調器...&#...]
n5[self.language_modules = self._register_langu...]
n6[self.coordination_history = []]
n7[self.ai_workload_distribution = {}]
n8[logger.info(f'✅ 已註冊 {len(self.la...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化多語言 AI 協調器&#39;]
n4[logger.info(&#39;🌐 初始化多語言 AI 協調器...&#...]
n5[self.language_modules = self._register_langu...]
n6[self.coordination_history = []]
n7[self.ai_workload_distribution = {}]
n8[logger.info(f&#39;✅ 已註冊 {len(self.la...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
331. core aiva core multilang coordinator Function analyze task requirements
flowchart TB
n1([開始])
n2([結束])
n3['分析任務需求']
n4[analysis = {'complexity_score...]
n5[description = task.description.low...]
n6[capability_mapping = {'ssrf'...]
n7{for (keyword, modules) in capability_mappin...}
n8{if keyword in description}
n9[analysis['required_capabilities&#...]
n10[analysis['complexity_score'...]
n11[]
n12[]
n13[analysis['required_capabilities&#...]
n14[analysis['complexity_score'...]
n15[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析任務需求&#39;]
n4[analysis = {&#39;complexity_score&#3...]
n5[description = task.description.low...]
n6[capability_mapping = {&#39;ssrf&#39;...]
n7{for (keyword, modules) in capability_mappin...}
n8{if keyword in description}
n9[analysis[&#39;required_capabilities&#...]
n10[analysis[&#39;complexity_score&#39;&#...]
n11[]
n12[]
n13[analysis[&#39;required_capabilities&#...]
n14[analysis[&#39;complexity_score&#39;&#...]
n15[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
332. core aiva core multilang coordinator Function distribute ai tasks
flowchart TB
n1([開始])
n2([結束])
n3['分配任務給各 AI 模組']
n4[assignments = {}]
n5{for module in selected_modules}
n6{if module.status == 'master'}
n7[assignments[module.module_name] = {&#...]
n8[assignments[module.module_name] = {&#...]
n9[]
n10[]
n11[return assignments]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分配任務給各 AI 模組&#39;]
n4[assignments = {}]
n5{for module in selected_modules}
n6{if module.status == &#39;master&#39;}
n7[assignments[module.module_name] = {&#...]
n8[assignments[module.module_name] = {&#...]
n9[]
n10[]
n11[return assignments]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
333. core aiva core multilang coordinator Function generate final recommendations
flowchart TB
n1([開始])
n2([結束])
n3['生成最終建議']
n4[recommendations = []]
n5{for (module_name, result) in execution_results...}
n6{if result['result'][&...}
n7{if 'detection_results' in resu...}
n8[recommendations.append(f'建議關注 {modul...]
n9{if 'analysis_results' in resul...}
n10[recommendations.append(f'參考 {module_...]
n11{if 'frontend_analysis' in resu...}
n12[recommendations.append(f'注意 {module_...]
n13[]
n14[]
n15[]
n16[]
n17[]
n18{if len(execution_results) > 2}
n19[recommendations.append('多語言 AI 協調良好,建議保持當...]
n20[]
n21[recommendations.append('定期更新各語言 AI 模組以維持最...]
n22[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n5
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成最終建議&#39;]
n4[recommendations = []]
n5{for (module_name, result) in execution_results...}
n6{if result[&#39;result&#39;][&...}
n7{if &#39;detection_results&#39; in resu...}
n8[recommendations.append(f&#39;建議關注 {modul...]
n9{if &#39;analysis_results&#39; in resul...}
n10[recommendations.append(f&#39;參考 {module_...]
n11{if &#39;frontend_analysis&#39; in resu...}
n12[recommendations.append(f&#39;注意 {module_...]
n13[]
n14[]
n15[]
n16[]
n17[]
n18{if len(execution_results) &gt; 2}
n19[recommendations.append(&#39;多語言 AI 協調良好,建議保持當...]
n20[]
n21[recommendations.append(&#39;定期更新各語言 AI 模組以維持最...]
n22[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 -->|Yes| n7
n6 -->|No| n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n5
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
334. core aiva core multilang coordinator Function generate master synthesis
flowchart TB
n1([開始])
n2([結束])
n3['生成主控 AI 綜合分析']
n4[successful_results = [r for r in executio...]
n5[languages_used = {r['language&...]
n6[synthesis = f'基於 {len(successful...]
n7[synthesis += f"涉及 {', &#...]
n8[synthesis += f'針對「{task.description}...]
n9{if len(successful_results) >= 3}
n10[synthesis += '多語言 AI 協同效果優異,各模組專業能力得到充分發揮。&am...]
n11{if len(successful_results) >= 2}
n12[synthesis += 'AI 協調運作正常,達到預期的分析效果。']
n13[synthesis += '基礎 AI 功能運作正常,建議啟用更多專業模組以增強分析能力。...]
n14[]
n15[]
n16[return synthesis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n15
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成主控 AI 綜合分析&#39;]
n4[successful_results = [r for r in executio...]
n5[languages_used = {r[&#39;language&&#...]
n6[synthesis = f&#39;基於 {len(successful...]
n7[synthesis += f&quot;涉及 {&#39;, &#...]
n8[synthesis += f&#39;針對「{task.description}...]
n9{if len(successful_results) &gt;= 3}
n10[synthesis += &#39;多語言 AI 協同效果優異,各模組專業能力得到充分發揮。&am...]
n11{if len(successful_results) &gt;= 2}
n12[synthesis += &#39;AI 協調運作正常,達到預期的分析效果。&#39;]
n13[synthesis += &#39;基礎 AI 功能運作正常,建議啟用更多專業模組以增強分析能力。...]
n14[]
n15[]
n16[return synthesis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n15
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
335. core aiva core multilang coordinator Function generate specific task
flowchart TB
n1([開始])
n2([結束])
n3['為特定 AI 模組生成具體任務']
n4[task_mapping = {'SSRFDetector...]
n5[return task_mapping.get(module.module...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;為特定 AI 模組生成具體任務&#39;]
n4[task_mapping = {&#39;SSRFDetector&#3...]
n5[return task_mapping.get(module.module...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
336. core aiva core multilang coordinator Function record coordination history
flowchart TB
n1([開始])
n2([結束])
n3['記錄協調歷史']
n4[history_entry = {'timestamp'...]
n5[self.coordination_history.append(history_entry)]
n6{if len(self.coordination_histo...}
n7[self.coordination_history.pop(0)]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄協調歷史&#39;]
n4[history_entry = {&#39;timestamp&#39;...]
n5[self.coordination_history.append(history_entry)]
n6{if len(self.coordination_histo...}
n7[self.coordination_history.pop(0)]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n2
337. core aiva core multilang coordinator Function register language modules
flowchart TB
n1([開始])
n2([結束])
n3['註冊各語言 AI 模組']
n4[modules = {'python_master': ...]
n5[return modules]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊各語言 AI 模組&#39;]
n4[modules = {&#39;python_master&#39;: ...]
n5[return modules]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
338. core aiva core multilang coordinator Function select optimal ai modules
flowchart TB
n1([開始])
n2([結束])
n3['選擇最佳 AI 模組組合']
n4[selected = []]
n5[selected.append(self.language_modules[...]
n6{for capability_module in analysis['requir...}
n7{if capability_module in self.l...}
n8[module = self.language_module...]
n9{if module.ai_active and module...}
n10[selected.append(module)]
n11[]
n12[]
n13[]
n14{if len(selected) == 1}
n15[selected.append(self.language_modules[...]
n16[]
n17[logger.info(f'🤖 選擇了 {len(selecte...]
n18{for module in selected}
n19[logger.info(f' {module.language...]
n20[]
n21[return selected]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n18
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;選擇最佳 AI 模組組合&#39;]
n4[selected = []]
n5[selected.append(self.language_modules[&#3...]
n6{for capability_module in analysis[&#39;requir...}
n7{if capability_module in self.l...}
n8[module = self.language_module...]
n9{if module.ai_active and module...}
n10[selected.append(module)]
n11[]
n12[]
n13[]
n14{if len(selected) == 1}
n15[selected.append(self.language_modules[&#3...]
n16[]
n17[logger.info(f&#39;🤖 選擇了 {len(selecte...]
n18{for module in selected}
n19[logger.info(f&#39; {module.language...]
n20[]
n21[return selected]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n6
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n18
n20 --> n21
n21 --> n2
339. core aiva core multilang coordinator Function get coordination statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取協調統計']
n4{if not self.coordination_history}
n5[return {'no_history': True...]
n6[]
n7[total_coordinations = len(self.coordinatio...]
n8[avg_efficiency = sum((h['coordina...]
n9[avg_success_rate = sum((h['succes...]
n10[language_usage = {}]
n11{for history in self.coordination...}
n12{for lang in history['language...}
n13[language_usage[lang] = language_usage.get(l...]
n14[]
n15[]
n16[return {'total_coordinations'...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n12
n14 --> n11
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取協調統計&#39;]
n4{if not self.coordination_history}
n5[return {&#39;no_history&#39;: True&#...]
n6[]
n7[total_coordinations = len(self.coordinatio...]
n8[avg_efficiency = sum((h[&#39;coordina...]
n9[avg_success_rate = sum((h[&#39;succes...]
n10[language_usage = {}]
n11{for history in self.coordination...}
n12{for lang in history[&#39;language...}
n13[language_usage[lang] = language_usage.get(l...]
n14[]
n15[]
n16[return {&#39;total_coordinations&#39...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n12
n14 --> n11
n15 --> n16
n16 --> n2
340. core aiva core nlg system Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化自然語言生成器']
n4[self.response_templates = self._init_response_...]
n5[self.context_analyzers = self._init_context_a...]
n6[self.personality_traits = {'professional...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化自然語言生成器&#39;]
n4[self.response_templates = self._init_response_...]
n5[self.context_analyzers = self._init_context_a...]
n6[self.personality_traits = {&#39;professional...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
341. core aiva core nlg system Function analyze context
flowchart TB
n1([開始])
n2([結束])
n3['分析上下文']
n4[user_input = context.get('user_in...]
n5[tool_result = context.get('tool_re...]
n6[bio_result = context.get('bio_res...]
n7[analyzed = {'user_input': us...]
n8[return analyzed]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析上下文&#39;]
n4[user_input = context.get(&#39;user_in...]
n5[tool_result = context.get(&#39;tool_re...]
n6[bio_result = context.get(&#39;bio_res...]
n7[analyzed = {&#39;user_input&#39;: us...]
n8[return analyzed]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
342. core aiva core nlg system Function analyze sentiment
flowchart TB
n1([開始])
n2([結束])
n3['分析情感傾向']
n4[sentiment = {'urgent': False...]
n5{for (emotion, patterns) in self.context_anal...}
n6[sentiment[emotion] = any((re.search(p...]
n7[]
n8[return sentiment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析情感傾向&#39;]
n4[sentiment = {&#39;urgent&#39;: False...]
n5{for (emotion, patterns) in self.context_anal...}
n6[sentiment[emotion] = any((re.search(p...]
n7[]
n8[return sentiment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n2
343. core aiva core nlg system Function detect intent
flowchart TB
n1([開始])
n2([結束])
n3['檢測用戶意圖']
n4[input_lower = user_input.lower()]
n5{for (intent, patterns) in self.context_anal...}
n6{if any((re.search(pattern, inp...}
n7[return intent.replace('_request&#...]
n8[]
n9[]
n10[return 'general']
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測用戶意圖&#39;]
n4[input_lower = user_input.lower()]
n5{for (intent, patterns) in self.context_anal...}
n6{if any((re.search(pattern, inp...}
n7[return intent.replace(&#39;_request&#...]
n8[]
n9[]
n10[return &#39;general&#39;]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
344. core aiva core nlg system Function determine response type
flowchart TB
n1([開始])
n2([結束])
n3['確定回應類型']
n4[intent = analyzed_context['in...]
n5[success = analyzed_context['su...]
n6[tool = analyzed_context['to...]
n7{if 'Reader' in tool}
n8[return 'code_operations.reading']
n9{if 'Writer' in tool}
n10[return 'code_operations.writing']
n11{if 'Analyzer' in tool}
n12[return 'code_operations.analysis']
n13{if 'Detector' in tool or inten...}
n14[return 'security_operations.scanning&#...]
n15{if intent == 'coordinate'}
n16[return 'system_control.coordination']
n17{if intent == 'status'}
n18[return 'communication.status']
n19[status = 'success' if success...]
n20[return f'task_completion.{status}&a...]
n21[]
n22[]
n23[]
n24[]
n25[]
n26[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n26
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n25
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n24
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n23
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n22
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n21
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;確定回應類型&#39;]
n4[intent = analyzed_context[&#39;in...]
n5[success = analyzed_context[&#39;su...]
n6[tool = analyzed_context[&#39;to...]
n7{if &#39;Reader&#39; in tool}
n8[return &#39;code_operations.reading&#39;]
n9{if &#39;Writer&#39; in tool}
n10[return &#39;code_operations.writing&#39;]
n11{if &#39;Analyzer&#39; in tool}
n12[return &#39;code_operations.analysis&#39;]
n13{if &#39;Detector&#39; in tool or inten...}
n14[return &#39;security_operations.scanning&#...]
n15{if intent == &#39;coordinate&#39;}
n16[return &#39;system_control.coordination&#39;]
n17{if intent == &#39;status&#39;}
n18[return &#39;communication.status&#39;]
n19[status = &#39;success&#39; if success...]
n20[return f&#39;task_completion.{status}&a...]
n21[]
n22[]
n23[]
n24[]
n25[]
n26[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n26
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n25
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n24
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n23
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n22
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n21
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
345. core aiva core nlg system Function extract entities
flowchart TB
n1([開始])
n2([結束])
n3['提取實體']
n4[entities = {'files': [...]
n5[file_matches = re.findall('\\b\\w+\...]
n6[entities['files'] = [...]
n7[vuln_patterns = self.context_analyze...]
n8{for pattern in vuln_patterns}
n9{if re.search(pattern, user_inp...}
n10[entities['vulnerabilities' ...]
n11[]
n12[]
n13[return entities]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取實體&#39;]
n4[entities = {&#39;files&#39;: [&#...]
n5[file_matches = re.findall(&#39;\\b\\w+\...]
n6[entities[&#39;files&#39;] = [...]
n7[vuln_patterns = self.context_analyze...]
n8{for pattern in vuln_patterns}
n9{if re.search(pattern, user_inp...}
n10[entities[&#39;vulnerabilities&#39;	...]
n11[]
n12[]
n13[return entities]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n2
346. core aiva core nlg system Function extract filename
flowchart TB
n1([開始])
n2([結束])
n3['提取檔案名稱']
n4[user_input = context.get('user_in...]
n5[files = context.get('entitie...]
n6{if files}
n7[return files[0]]
n8[]
n9[file_match = re.search('\\b(\\w+\...]
n10{if file_match}
n11[return file_match.group(1)]
n12[]
n13[return '目標檔案']
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取檔案名稱&#39;]
n4[user_input = context.get(&#39;user_in...]
n5[files = context.get(&#39;entitie...]
n6{if files}
n7[return files[0]]
n8[]
n9[file_match = re.search(&#39;\\b(\\w+\...]
n10{if file_match}
n11[return file_match.group(1)]
n12[]
n13[return &#39;目標檔案&#39;]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n2
347. core aiva core nlg system Function extract technical details
flowchart TB
n1([開始])
n2([結束])
n3['提取技術細節']
n4[details = {}]
n5{if 'lines' in tool_result}
n6[details['lines'] = tool_r...]
n7[]
n8{if 'bytes_written' in tool_result}
n9[details['bytes_written'] ...]
n10[]
n11{if 'analysis' in tool_result}
n12[details['analysis'] = too...]
n13[]
n14{if 'vulnerabilities_found' in ...}
n15[details['vulnerabilities_found...]
n16[]
n17[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取技術細節&#39;]
n4[details = {}]
n5{if &#39;lines&#39; in tool_result}
n6[details[&#39;lines&#39;] = tool_r...]
n7[]
n8{if &#39;bytes_written&#39; in tool_result}
n9[details[&#39;bytes_written&#39;] ...]
n10[]
n11{if &#39;analysis&#39; in tool_result}
n12[details[&#39;analysis&#39;] = too...]
n13[]
n14{if &#39;vulnerabilities_found&#39; in ...}
n15[details[&#39;vulnerabilities_found&#3...]
n16[]
n17[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
348. core aiva core nlg system Function fill template
flowchart TB
n1([開始])
n2([結束])
n3['填充模板變數']
n4[variables = {'action': conte...]
n5[try]
n6[return template.format(**variables)]
n7[]
n8[except KeyError]
n9[missing_var = str(e).strip("&...]
n10[variables[missing_var] = f'[{...]
n11[return template.format(**variables)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n8
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
flowchart TB
n1([開始])
n2([結束])
n3[&#39;填充模板變數&#39;]
n4[variables = {&#39;action&#39;: conte...]
n5[try]
n6[return template.format(**variables)]
n7[]
n8[except KeyError]
n9[missing_var = str(e).strip(&quot;&...]
n10[variables[missing_var] = f&#39;[{...]
n11[return template.format(**variables)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n8
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
349. core aiva core nlg system Function generate result detail
flowchart TB
n1([開始])
n2([結束])
n3['生成結果詳情']
n4[tool_result = context.get('tool_re...]
n5[tech_details = context.get('technic...]
n6{if 'lines' in tech_details}
n7[return f"讀取了 {tech_details['...]
n8{if 'bytes_written' in tech_det...}
n9[return f"成功寫入 {tech_details[...]
n10{if 'analysis' in tech_details}
n11[return f"分析結果:{tech_details[...]
n12{if tool_result.get('status'...}
n13[return '操作成功完成']
n14[return '處理完成']
n15[]
n16[]
n17[]
n18[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n18
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n17
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成結果詳情&#39;]
n4[tool_result = context.get(&#39;tool_re...]
n5[tech_details = context.get(&#39;technic...]
n6{if &#39;lines&#39; in tech_details}
n7[return f&quot;讀取了 {tech_details[&#39...]
n8{if &#39;bytes_written&#39; in tech_det...}
n9[return f&quot;成功寫入 {tech_details[&#3...]
n10{if &#39;analysis&#39; in tech_details}
n11[return f&quot;分析結果:{tech_details[&#3...]
n12{if tool_result.get(&#39;status&#39;&#...}
n13[return &#39;操作成功完成&#39;]
n14[return &#39;處理完成&#39;]
n15[]
n16[]
n17[]
n18[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n18
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n17
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
350. core aiva core nlg system Function init context analyzers
flowchart TB
n1([開始])
n2([結束])
n3['初始化上下文分析器']
n4[return {'intent_patterns': &...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化上下文分析器&#39;]
n4[return {&#39;intent_patterns&#39;: &...]
n1 --> n3
n3 --> n4
n4 --> n2
351. core aiva core nlg system Function init response templates
flowchart TB
n1([開始])
n2([結束])
n3['初始化回應模板']
n4[return {'task_completion': &...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化回應模板&#39;]
n4[return {&#39;task_completion&#39;: &...]
n1 --> n3
n3 --> n4
n4 --> n2
352. core aiva core nlg system Function post process response
flowchart TB
n1([開始])
n2([結束])
n3['後處理優化回應']
n4{if not any((marker in response...}
n5[aiva_signatures = ['(AIVA 自主執行)&a...]
n6[response += f' {random.choice(aiva_s...]
n7[]
n8[confidence = context.get('confide...]
n9{if confidence < 0.5}
n10[response = response.replace('✅...]
n11{if confidence > 0.9}
n12[response = response.replace('完成...]
n13[]
n14[]
n15[return response]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;後處理優化回應&#39;]
n4{if not any((marker in response...}
n5[aiva_signatures = [&#39;(AIVA 自主執行)&a...]
n6[response += f&#39; {random.choice(aiva_s...]
n7[]
n8[confidence = context.get(&#39;confide...]
n9{if confidence &lt; 0.5}
n10[response = response.replace(&#39;✅&#3...]
n11{if confidence &gt; 0.9}
n12[response = response.replace(&#39;完成...]
n13[]
n14[]
n15[return response]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
353. core aiva core nlg system Function select template
flowchart TB
n1([開始])
n2([結束])
n3['選擇合適的模板']
n4[type_parts = response_type.split(...]
n5[category = type_parts[0]]
n6[subcategory = type_parts[1] if len...]
n7[templates = self.response_templa...]
n8{if not templates}
n9[return '✅ 任務已完成,結果:{result_summary}...]
n10[]
n11{if context.get('sentiment', &...}
n12[return min(templates, key=len)]
n13{if context.get('sentiment', &...}
n14[return templates[-1] if templates els...]
n15[return random.choice(templates)]
n16[]
n17[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n17
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n16
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;選擇合適的模板&#39;]
n4[type_parts = response_type.split(...]
n5[category = type_parts[0]]
n6[subcategory = type_parts[1] if len...]
n7[templates = self.response_templa...]
n8{if not templates}
n9[return &#39;✅ 任務已完成,結果:{result_summary}...]
n10[]
n11{if context.get(&#39;sentiment&#39;, &...}
n12[return min(templates, key=len)]
n13{if context.get(&#39;sentiment&#39;, &...}
n14[return templates[-1] if templates els...]
n15[return random.choice(templates)]
n16[]
n17[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n17
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n16
n15 --> n16
n16 --> n17
n17 --> n2
354. core aiva core nlg system Function generate response
flowchart TB
n1([開始])
n2([結束])
n3['生成自然語言回應']
n4[analyzed_context = self._analyze_contex...]
n5{if response_type == 'auto'}
n6[response_type = self._determine_resp...]
n7[]
n8[template = self._select_templat...]
n9[response = self._fill_template(...]
n10[final_response = self._post_process_r...]
n11[return final_response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成自然語言回應&#39;]
n4[analyzed_context = self._analyze_contex...]
n5{if response_type == &#39;auto&#39;}
n6[response_type = self._determine_resp...]
n7[]
n8[template = self._select_templat...]
n9[response = self._fill_template(...]
n10[final_response = self._post_process_r...]
n11[return final_response]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
355. core aiva core nlg system Function test nlg system
flowchart TB
n1([開始])
n2([結束])
n3['測試自然語言生成系統']
n4[print('🧠 AIVA 自然語言生成系統測試')]
n5[print('=' * 40)]
n6[nlg = AIVANaturalLanguageG...]
n7[test_contexts = [{'user_input&...]
n8{for (i, context) in enumerate(test_co...}
n9[print(f"\n測試 {i}: {context ...]
n10[response = nlg.generate_respons...]
n11[print(f'AIVA: {response}&...]
n12[]
n13[print('\n✅ 自然語言生成測試完成!')]
n14[print('💡 AIVA 無需 GPT-4 也能生成高品質中文回應&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試自然語言生成系統&#39;]
n4[print(&#39;🧠 AIVA 自然語言生成系統測試&#39;)]
n5[print(&#39;=&#39; * 40)]
n6[nlg = AIVANaturalLanguageG...]
n7[test_contexts = [{&#39;user_input&&#...]
n8{for (i, context) in enumerate(test_co...}
n9[print(f&quot;\n測試 {i}: {context	...]
n10[response = nlg.generate_respons...]
n11[print(f&#39;AIVA: {response}&&#...]
n12[]
n13[print(&#39;\n✅ 自然語言生成測試完成!&#39;)]
n14[print(&#39;💡 AIVA 無需 GPT-4 也能生成高品質中文回應&&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 --> n2
356. core aiva core optimized core Function init
flowchart TB
n1([開始])
n2([結束])
n3[print('🧠 AIVA 自主 AI 分析中...')]
n4[self.analyze_current_capabilities()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[print(&#39;🧠 AIVA 自主 AI 分析中...&#39;)]
n4[self.analyze_current_capabilities()]
n1 --> n3
n3 --> n4
n4 --> n2
357. core aiva core optimized core Function get cache key
flowchart TB
n1([開始])
n2([結束])
n3['生成快取鍵值']
n4[return str(hash(x.tobytes()))]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成快取鍵值&#39;]
n4[return str(hash(x.tobytes()))]
n1 --> n3
n3 --> n4
n4 --> n2
358. core aiva core optimized core Function get memory usage mb
flowchart TB
n1([開始])
n2([結束])
n3['獲取當前記憶體使用量(MB)']
n4[try]
n5[import psutil]
n6[process = psutil.Process()]
n7[return process.memory_info().rss / 10...]
n8[]
n9[except ImportError]
n10[import tracemalloc]
n11{if tracemalloc.is_tracing()}
n12[(current, peak) = tracemalloc.get_trac...]
n13[return current / 1024 / 1024]
n14[]
n15[return 0.0]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n9
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n15
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n8
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取當前記憶體使用量(MB)&#39;]
n4[try]
n5[import psutil]
n6[process = psutil.Process()]
n7[return process.memory_info().rss / 10...]
n8[]
n9[except ImportError]
n10[import tracemalloc]
n11{if tracemalloc.is_tracing()}
n12[(current, peak) = tracemalloc.get_trac...]
n13[return current / 1024 / 1024]
n14[]
n15[return 0.0]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n9
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n15
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n8
n15 --> n2
359. core aiva core optimized core Function make key
flowchart TB
n1([開始])
n2([結束])
n3['生成指標鍵值']
n4{if not labels}
n5[return name]
n6[]
n7[label_str = '_'.join((f&a...]
n8[return f'{name}_{hash(labe...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成指標鍵值&#39;]
n4{if not labels}
n5[return name]
n6[]
n7[label_str = &#39;_&#39;.join((f&a...]
n8[return f&#39;{name}_{hash(labe...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
360. core aiva core optimized core Function update avg duration
flowchart TB
n1([開始])
n2([結束])
n3['更新平均處理時間']
n4[count = self.processing_stat...]
n5[current_avg = self.processing_stat...]
n6[new_avg = (current_avg * (coun...]
n7[self.processing_stats['avg_duration&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新平均處理時間&#39;]
n4[count = self.processing_stat...]
n5[current_avg = self.processing_stat...]
n6[new_avg = (current_avg * (coun...]
n7[self.processing_stats[&#39;avg_duration&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
361. core aiva core optimized core Function analyze current capabilities
flowchart TB
n1([開始])
n2([結束])
n3['分析 AIVA 現有的 AI 能力']
n4[print('\n📊 AIVA 現有 AI 能力盤點:'&...]
n5[capabilities = {'BioNeuronRAGAgent&&...]
n6{for (name, info) in capabilities.items()}
n7[print(f'\n✅ {name}:'...]
n8[print(f" {info['描述&am...]
n9[print(f" 功能: {', &...]
n10[print(f" 自主性: {info['...]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析 AIVA 現有的 AI 能力&#39;]
n4[print(&#39;\n📊 AIVA 現有 AI 能力盤點:&#39;&...]
n5[capabilities = {&#39;BioNeuronRAGAgent&&...]
n6{for (name, info) in capabilities.items()}
n7[print(f&#39;\n✅ {name}:&#39...]
n8[print(f&quot; {info[&#39;描述&am...]
n9[print(f&quot; 功能: {&#39;, &...]
n10[print(f&quot; 自主性: {info[&#39;...]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n2
362. core aiva core optimized core Function clear cache
flowchart TB
n1([開始])
n2([結束])
n3['清空快取']
n4[self._prediction_cache.clear()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清空快取&#39;]
n4[self._prediction_cache.clear()]
n1 --> n3
n3 --> n4
n4 --> n2
363. core aiva core optimized core Function compare with gpt4
flowchart TB
n1([開始])
n2([結束])
n3['比較 AIVA vs GPT-4 在程式控制場景的適用性']
n4[print('\n🆚 AIVA vs GPT-4 比較 (程式控制場景...]
n5[comparison = {'離線運作': {...]
n6{for (aspect, scores) in comparison.items()}
n7[print(f'\n{aspect}:'...]
n8[print(f" AIVA: {scores[&#...]
n9[print(f" GPT-4: {scores[&#...]
n10[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n6
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;比較 AIVA vs GPT-4 在程式控制場景的適用性&#39;]
n4[print(&#39;\n🆚 AIVA vs GPT-4 比較 (程式控制場景&#...]
n5[comparison = {&#39;離線運作&#39;: {...]
n6{for (aspect, scores) in comparison.items()}
n7[print(f&#39;\n{aspect}:&#39...]
n8[print(f&quot; AIVA: {scores[&#...]
n9[print(f&quot; GPT-4: {scores[&#...]
n10[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n6
n10 --> n2
364. core aiva core optimized core Function decorator
flowchart TB
n1([開始])
n2([結束])
n3[def wrapper(...)]
n4[return wrapper]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[def wrapper(...)]
n4[return wrapper]
n1 --> n3
n3 --> n4
n4 --> n2
365. core aiva core optimized core Function demonstrate self sufficiency
flowchart TB
n1([開始])
n2([結束])
n3['展示 AIVA 的自給自足能力']
n4[print('\n🎯 AIVA 自給自足能力展示:')]
n5[scenarios = [{'場景': &...]
n6{for (i, scenario) in enumerate(scenari...}
n7[print(f"\n情境 {i}: {scenario...]
n8[print(f" AIVA 處理流程: {scenario[&...]
n9[print(f" {scenario['需要...]
n10[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n6
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;展示 AIVA 的自給自足能力&#39;]
n4[print(&#39;\n🎯 AIVA 自給自足能力展示:&#39;)]
n5[scenarios = [{&#39;場景&#39;: &...]
n6{for (i, scenario) in enumerate(scenari...}
n7[print(f&quot;\n情境 {i}: {scenario&#...]
n8[print(f&quot; AIVA 處理流程: {scenario[&...]
n9[print(f&quot; {scenario[&#39;需要...]
n10[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n6
n10 --> n2
366. core aiva core optimized core Function final verdict
flowchart TB
n1([開始])
n2([結束])
n3['最終結論']
n4[print('\n' + '=&a...]
n5[print('🏆 最終結論: AIVA 完全不需要 GPT-4!&#...]
n6[print('=' * 60)]
n7[reasons = ['🧠 已有完整的生物神經網路 AI'...]
n8[print('\n✅ AIVA 的完全自主能力:')]
n9{for reason in reasons}
n10[print(f' {reason}'...]
n11[]
n12[print('\n📈 自主性評分: 100/100')]
n13[print('💯 結論: AIVA 自己就行!不需要外部 AI!&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n9
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;最終結論&#39;]
n4[print(&#39;\n&#39; + &#39;=&a...]
n5[print(&#39;🏆 最終結論: AIVA 完全不需要 GPT-4!&#...]
n6[print(&#39;=&#39; * 60)]
n7[reasons = [&#39;🧠 已有完整的生物神經網路 AI&#39;...]
n8[print(&#39;\n✅ AIVA 的完全自主能力:&#39;)]
n9{for reason in reasons}
n10[print(f&#39; {reason}&#39...]
n11[]
n12[print(&#39;\n📈 自主性評分: 100/100&#39;)]
n13[print(&#39;💯 結論: AIVA 自己就行!不需要外部 AI!&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n9
n11 --> n12
n12 --> n13
n13 --> n2
367. core aiva core optimized core Function get cache stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取快取統計']
n4[return {'cache_size': len...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取快取統計&#39;]
n4[return {&#39;cache_size&#39;: len...]
n1 --> n3
n3 --> n4
n4 --> n2
368. core aiva core optimized core Function get memory stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取記憶體統計']
n4[return {'current_memory_mb':...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取記憶體統計&#39;]
n4[return {&#39;current_memory_mb&#39;:...]
n1 --> n3
n3 --> n4
n4 --> n2
369. core aiva core optimized core Function get metrics summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取指標摘要']
n4[summary = {'counters': dict&...]
n5{for (name, metrics) in self.metrics.items()}
n6{if metrics}
n7[durations = [m.value for m in me...]
n8[summary['durations'][...]
n9[]
n10[]
n11[return summary]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取指標摘要&#39;]
n4[summary = {&#39;counters&#39;: dict&...]
n5{for (name, metrics) in self.metrics.items()}
n6{if metrics}
n7[durations = [m.value for m in me...]
n8[summary[&#39;durations&#39;][...]
n9[]
n10[]
n11[return summary]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
370. core aiva core optimized core Function get pool stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取池子統計資訊']
n4[return {'pool_size': self.po...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取池子統計資訊&#39;]
n4[return {&#39;pool_size&#39;: self.po...]
n1 --> n3
n3 --> n4
n4 --> n2
371. core aiva core optimized core Function increment counter
flowchart TB
n1([開始])
n2([結束])
n3['增加計數器']
n4[key = self._make_key(name,...]
n5[self.counters[key] += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;增加計數器&#39;]
n4[key = self._make_key(name,...]
n5[self.counters[key] += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
372. core aiva core optimized core Function monitor performance
flowchart TB
n1([開始])
n2([結束])
n3['效能監控裝飾器']
n4[def decorator(...)]
n5[return decorator]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;效能監控裝飾器&#39;]
n4[def decorator(...)]
n5[return decorator]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
373. core aiva core optimized core Function prove aiva independence
flowchart TB
n1([開始])
n2([結束])
n3['執行 AIVA 獨立性證明']
n4[print('🔬 AIVA AI 獨立性分析報告')]
n5[print('=' * 50)]
n6[proof = AIVAAutonomyProof()]
n7[proof.compare_with_gpt4()]
n8[proof.demonstrate_self_sufficiency()]
n9[proof.final_verdict()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行 AIVA 獨立性證明&#39;]
n4[print(&#39;🔬 AIVA AI 獨立性分析報告&#39;)]
n5[print(&#39;=&#39; * 50)]
n6[proof = AIVAAutonomyProof()]
n7[proof.compare_with_gpt4()]
n8[proof.demonstrate_self_sufficiency()]
n9[proof.final_verdict()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
374. core aiva core optimized core Function record duration
flowchart TB
n1([開始])
n2([結束])
n3['記錄執行時間']
n4[metric = Metric(name, duratio...]
n5[self.metrics[f'{name}_duration&...]
n6{if len(self.metrics[f'{name}...}
n7[self.metrics[f'{name}_duration&...]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄執行時間&#39;]
n4[metric = Metric(name, duratio...]
n5[self.metrics[f&#39;{name}_duration&...]
n6{if len(self.metrics[f&#39;{name}...}
n7[self.metrics[f&#39;{name}_duration&...]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n2
375. core aiva core optimized core Function register weak ref
flowchart TB
n1([開始])
n2([結束])
n3['註冊弱引用']
n4[self.weak_refs.add(obj)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊弱引用&#39;]
n4[self.weak_refs.add(obj)]
n1 --> n3
n3 --> n4
n4 --> n2
376. core aiva core optimized core Function return component
flowchart TB
n1([開始])
n2([結束])
n3['歸還組件到池中']
n4{if hasattr(component, 'reset'...}
n5[component.reset()]
n6[]
n7[try]
n8[self.pool.put_nowait(component)]
n9[self.active_components.discard(id(component)&...]
n10[]
n11[except asyncio.Queu...]
n12[pass]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n11
n8 --> n9
n9 --> n10
n10 --> n2
n11 --> n12
n12 --> n10
flowchart TB
n1([開始])
n2([結束])
n3[&#39;歸還組件到池中&#39;]
n4{if hasattr(component, &#39;reset&#39;...}
n5[component.reset()]
n6[]
n7[try]
n8[self.pool.put_nowait(component)]
n9[self.active_components.discard(id(component)&...]
n10[]
n11[except asyncio.Queu...]
n12[pass]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n11
n8 --> n9
n9 --> n10
n10 --> n2
n11 --> n12
n12 --> n10
377. core aiva core optimized core Function set gauge
flowchart TB
n1([開始])
n2([結束])
n3['設置儀表值']
n4[key = self._make_key(name,...]
n5[self.gauges[key] = Metric(name, value, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置儀表值&#39;]
n4[key = self._make_key(name,...]
n5[self.gauges[key] = Metric(name, value, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
378. core aiva core output to functions Function to function message
flowchart TB
n1([開始])
n2([結束])
n3['Wrap function payload into AIVA message with...]
n4[return AivaMessage(header=MessageHead...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Wrap function payload into AIVA message with...]
n4[return AivaMessage(header=MessageHead...]
n1 --> n3
n3 --> n4
n4 --> n2
379. core aiva core output to functions Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from services.aiva_common.enums import ModuleName,...]
n5[from services.aiva_common.schemas import AivaMessa...]
n6[from services.aiva_common.utils import new_id]
n7[def to_function_message(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from services.aiva_common.enums import ModuleName,...]
n5[from services.aiva_common.schemas import AivaMessa...]
n6[from services.aiva_common.utils import new_id]
n7[def to_function_message(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
380. core aiva core planner ast parser Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化解析器']
n4[logger.info('ASTParser initialized&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化解析器&#39;]
n4[logger.info(&#39;ASTParser initialized&&#...]
n1 --> n3
n3 --> n4
n4 --> n2
381. core aiva core planner ast parser Function repr
flowchart TB
n1([開始])
n2([結束])
n3[cond = f' [{self.condition}...]
n4[return f'{self.from_node} ->...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[cond = f&#39; [{self.condition}...]
n4[return f&#39;{self.from_node} -&gt;...]
n1 --> n3
n3 --> n4
n4 --> n2
382. core aiva core planner ast parser Function add edge
flowchart TB
n1([開始])
n2([結束])
n3['添加邊']
n4{if edge.from_node not in self....}
n5[raise ValueError(f'Source node {edge...]
n6[]
n7{if edge.to_node not in self.nodes}
n8[raise ValueError(f'Target node {edge...]
n9[]
n10[self.edges.append(edge)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加邊&#39;]
n4{if edge.from_node not in self....}
n5[raise ValueError(f&#39;Source node {edge...]
n6[]
n7{if edge.to_node not in self.nodes}
n8[raise ValueError(f&#39;Target node {edge...]
n9[]
n10[self.edges.append(edge)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
383. core aiva core planner ast parser Function add node
flowchart TB
n1([開始])
n2([結束])
n3['添加節點']
n4[self.nodes[node.node_id] = node]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加節點&#39;]
n4[self.nodes[node.node_id] = node]
n1 --> n3
n3 --> n4
n4 --> n2
384. core aiva core planner ast parser Function create example sqli flow
flowchart TB
n1([開始])
n2([結束])
n3['創建一個 SQL 注入攻擊流程的範例\n\n Returns:\n ...]
n4[graph = AttackFlowGraph(grap...]
n5[nodes = [AttackFlowNode('n0&#...]
n6{for node in nodes}
n7[graph.add_node(node)]
n8[]
n9[edges = [AttackFlowEdge('n0&#...]
n10{for edge in edges}
n11[graph.add_edge(edge)]
n12[]
n13[return graph]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建一個 SQL 注入攻擊流程的範例\n\n Returns:\n ...]
n4[graph = AttackFlowGraph(grap...]
n5[nodes = [AttackFlowNode(&#39;n0&#...]
n6{for node in nodes}
n7[graph.add_node(node)]
n8[]
n9[edges = [AttackFlowEdge(&#39;n0&#...]
n10{for edge in edges}
n11[graph.add_edge(edge)]
n12[]
n13[return graph]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n2
385. core aiva core planner ast parser Function get next nodes
flowchart TB
n1([開始])
n2([結束])
n3['獲取指定節點的下一步節點']
n4[next_nodes = []]
n5{for edge in self.edges}
n6{if edge.from_node == current_n...}
n7[next_nodes.append(self.nodes[edge.to_node])]
n8[]
n9[]
n10[return next_nodes]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取指定節點的下一步節點&#39;]
n4[next_nodes = []]
n5{for edge in self.edges}
n6{if edge.from_node == current_n...}
n7[next_nodes.append(self.nodes[edge.to_node])]
n8[]
n9[]
n10[return next_nodes]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
386. core aiva core planner ast parser Function get start node
flowchart TB
n1([開始])
n2([結束])
n3['獲取開始節點']
n4{for node in self.nodes.values()}
n5{if node.node_type == NodeType....}
n6[return node]
n7[]
n8[]
n9[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取開始節點&#39;]
n4{for node in self.nodes.values()}
n5{if node.node_type == NodeType....}
n6[return node]
n7[]
n8[]
n9[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
387. core aiva core planner ast parser Function parse dict
flowchart TB
n1([開始])
n2([結束])
n3['從字典格式解析 AST\n\n Args:\n as...]
n4[graph_id = ast_dict.get('graph_...]
n5[graph = AttackFlowGraph(grap...]
n6{for node_dict in ast_dict.get('nod...}
n7[node = AttackFlowNode(node_...]
n8[graph.add_node(node)]
n9[]
n10{for edge_dict in ast_dict.get('edg...}
n11[edge = AttackFlowEdge(from_...]
n12[graph.add_edge(edge)]
n13[]
n14[(is_valid, errors) = graph.validate()]
n15{if not is_valid}
n16[logger.warning(f'AST validation errors: &...]
n17[]
n18[logger.info(f"Parsed AST graph '...]
n19[return graph]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n6
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從字典格式解析 AST\n\n Args:\n as...]
n4[graph_id = ast_dict.get(&#39;graph_...]
n5[graph = AttackFlowGraph(grap...]
n6{for node_dict in ast_dict.get(&#39;nod...}
n7[node = AttackFlowNode(node_...]
n8[graph.add_node(node)]
n9[]
n10{for edge_dict in ast_dict.get(&#39;edg...}
n11[edge = AttackFlowEdge(from_...]
n12[graph.add_edge(edge)]
n13[]
n14[(is_valid, errors) = graph.validate()]
n15{if not is_valid}
n16[logger.warning(f&#39;AST validation errors: &...]
n17[]
n18[logger.info(f&quot;Parsed AST graph &#39;...]
n19[return graph]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n6
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
388. core aiva core planner ast parser Function parse text
flowchart TB
n1([開始])
n2([結束])
n3['從文本格式解析 AST\n\n 支持簡單的文本格式,例如:\n ...]
n4[logger.warning('Text parsing not fully im...]
n5[graph = AttackFlowGraph(grap...]
n6[return graph]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從文本格式解析 AST\n\n 支持簡單的文本格式,例如:\n ...]
n4[logger.warning(&#39;Text parsing not fully im...]
n5[graph = AttackFlowGraph(grap...]
n6[return graph]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
389. core aiva core planner ast parser Function validate
flowchart TB
n1([開始])
n2([結束])
n3['驗證圖的完整性\n\n Returns:\n ...]
n4[errors = []]
n5{if not self.get_start_node()}
n6[errors.append('Missing START node&...]
n7[]
n8[has_end = any((n.node_type == ...]
n9{if not has_end}
n10[errors.append('Missing END node&#...]
n11[]
n12[connected_nodes = set()]
n13{for edge in self.edges}
n14[connected_nodes.add(edge.from_node)]
n15[connected_nodes.add(edge.to_node)]
n16[]
n17{for node_id in self.nodes}
n18{if node_id not in connected_nodes}
n19[errors.append(f'Isolated node: {node...]
n20[]
n21[]
n22[return (len(errors) == 0, errors)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n13
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n17
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證圖的完整性\n\n Returns:\n ...]
n4[errors = []]
n5{if not self.get_start_node()}
n6[errors.append(&#39;Missing START node&...]
n7[]
n8[has_end = any((n.node_type == ...]
n9{if not has_end}
n10[errors.append(&#39;Missing END node&#...]
n11[]
n12[connected_nodes = set()]
n13{for edge in self.edges}
n14[connected_nodes.add(edge.from_node)]
n15[connected_nodes.add(edge.to_node)]
n16[]
n17{for node_id in self.nodes}
n18{if node_id not in connected_nodes}
n19[errors.append(f&#39;Isolated node: {node...]
n20[]
n21[]
n22[return (len(errors) == 0, errors)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n13
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n17
n21 --> n22
n22 --> n2
390. core aiva core planner orchestrator Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化編排器']
n4[self.ast_parser = ASTParser()]
n5[self.task_converter = TaskConverter()]
n6[self.tool_selector = ToolSelector()]
n7[logger.info('AttackOrchestrator initializ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化編排器&#39;]
n4[self.ast_parser = ASTParser()]
n5[self.task_converter = TaskConverter()]
n6[self.tool_selector = ToolSelector()]
n7[logger.info(&#39;AttackOrchestrator initializ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
391. core aiva core planner orchestrator Function create execution plan
flowchart TB
n1([開始])
n2([結束])
n3['創建執行計畫\n\n Args:\n ast_inp...]
n4[plan_id = f'plan_{uuid4().hex ...]
n5[logger.info(f'Creating execution plan ...]
n6{if isinstance(ast_input, dict)}
n7[graph = self.ast_parser.pars...]
n8{if isinstance(ast_input, Attac...}
n9[graph = ast_input]
n10[raise ValueError(f'Unsupported AST input ...]
n11[]
n12[]
n13[task_sequence = self.task_converter....]
n14[tool_decisions: dict[str, ToolDecision] = {&...]
n15{for task in task_sequence.tasks}
n16[decision = self.tool_selector.s...]
n17[tool_decisions[task.task_id] = decision]
n18[]
n19[plan = ExecutionPlan(plan_i...]
n20[logger.info(f'Execution plan {plan_i...]
n21[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建執行計畫\n\n Args:\n ast_inp...]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[logger.info(f&#39;Creating execution plan ...]
n6{if isinstance(ast_input, dict)}
n7[graph = self.ast_parser.pars...]
n8{if isinstance(ast_input, Attac...}
n9[graph = ast_input]
n10[raise ValueError(f&#39;Unsupported AST input ...]
n11[]
n12[]
n13[task_sequence = self.task_converter....]
n14[tool_decisions: dict[str, ToolDecision] = {&...]
n15{for task in task_sequence.tasks}
n16[decision = self.tool_selector.s...]
n17[tool_decisions[task.task_id] = decision]
n18[]
n19[plan = ExecutionPlan(plan_i...]
n20[logger.info(f&#39;Execution plan {plan_i...]
n21[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
392. core aiva core planner orchestrator Function get decision for task
flowchart TB
n1([開始])
n2([結束])
n3['獲取任務的工具選擇決策']
n4[return self.tool_decisions.get(task_i...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取任務的工具選擇決策&#39;]
n4[return self.tool_decisions.get(task_i...]
n1 --> n3
n3 --> n4
n4 --> n2
393. core aiva core planner orchestrator Function get next executable tasks
flowchart TB
n1([開始])
n2([結束])
n3['獲取下一批可執行的任務及其工具決策\n\n Args:\n ...]
n4[runnable_tasks = plan.task_sequence.g...]
n5[result = []]
n6{for task in runnable_tasks}
n7[decision = plan.get_decision_fo...]
n8{if decision}
n9[result.append((task, decision))]
n10[]
n11[]
n12[logger.debug(f'Found {len(result...]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取下一批可執行的任務及其工具決策\n\n Args:\n ...]
n4[runnable_tasks = plan.task_sequence.g...]
n5[result = []]
n6{for task in runnable_tasks}
n7[decision = plan.get_decision_fo...]
n8{if decision}
n9[result.append((task, decision))]
n10[]
n11[]
n12[logger.debug(f&#39;Found {len(result...]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n13
n13 --> n2
394. core aiva core planner orchestrator Function get plan summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取執行計畫摘要\n\n Args:\n plan:...]
n4[tasks = plan.task_sequence.t...]
n5[status_counts = {}]
n6{for status in TaskStatus}
n7[status_counts[status.value] = sum((1 for ...]
n8[]
n9[return {'plan_id': plan.plan...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取執行計畫摘要\n\n Args:\n plan:...]
n4[tasks = plan.task_sequence.t...]
n5[status_counts = {}]
n6{for status in TaskStatus}
n7[status_counts[status.value] = sum((1 for ...]
n8[]
n9[return {&#39;plan_id&#39;: plan.plan...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n2
395. core aiva core planner orchestrator Function is plan complete
flowchart TB
n1([開始])
n2([結束])
n3['檢查執行計畫是否已完成\n\n Args:\n pl...]
n4{for task in plan.task_sequenc...}
n5{if task.status in (TaskStatus....}
n6[return False]
n7[]
n8[]
n9[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查執行計畫是否已完成\n\n Args:\n pl...]
n4{for task in plan.task_sequenc...}
n5{if task.status in (TaskStatus....}
n6[return False]
n7[]
n8[]
n9[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
396. core aiva core planner orchestrator Function update task status
flowchart TB
n1([開始])
n2([結束])
n3['更新任務狀態\n\n Args:\n plan: 執...]
n4[task = plan.task_sequence.g...]
n5{if not task}
n6[logger.warning(f'Task {task_id}...]
n7[return]
n8[]
n9[task.status = status]
n10[task.result = result]
n11[task.error = error]
n12[logger.info(f'Task {task_id} st...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新任務狀態\n\n Args:\n plan: 執...]
n4[task = plan.task_sequence.g...]
n5{if not task}
n6[logger.warning(f&#39;Task {task_id}...]
n7[return]
n8[]
n9[task.status = status]
n10[task.result = result]
n11[task.error = error]
n12[logger.info(f&#39;Task {task_id} st...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
397. core aiva core planner task converter Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化任務轉換器']
n4[logger.info('TaskConverter initialized&am...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化任務轉換器&#39;]
n4[logger.info(&#39;TaskConverter initialized&am...]
n1 --> n3
n3 --> n4
n4 --> n2
398. core aiva core planner task converter Function repr
flowchart TB
n1([開始])
n2([結束])
n3[return f'Task({self.task_id}:...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return f&#39;Task({self.task_id}:&#...]
n1 --> n3
n3 --> n2
399. core aiva core planner task converter Function create task from node
flowchart TB
n1([開始])
n2([結束])
n3['從 AST 節點創建可執行任務\n\n Args:\n ...]
n4[task_id = f'task_{uuid4().hex ...]
n5[task_type_map = {NodeType.SCAN: 'sca...]
n6[task_type = task_type_map.get(no...]
n7[priority_map = {NodeType.SCAN: Task...]
n8[priority = priority_map.get(nod...]
n9[task = ExecutableTask(task_...]
n10[return task]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從 AST 節點創建可執行任務\n\n Args:\n ...]
n4[task_id = f&#39;task_{uuid4().hex	...]
n5[task_type_map = {NodeType.SCAN: &#39;sca...]
n6[task_type = task_type_map.get(no...]
n7[priority_map = {NodeType.SCAN: Task...]
n8[priority = priority_map.get(nod...]
n9[task = ExecutableTask(task_...]
n10[return task]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
400. core aiva core planner task converter Function topological sort
flowchart TB
n1([開始])
n2([結束])
n3['拓撲排序\n\n Args:\n graph: 攻擊...]
n4[visited = set()]
n5[result = []]
n6[start_node = graph.get_start_node...]
n7{if not start_node}
n8[return list(graph.nodes.values())]
n9[]
n10[queue = [start_node]]
n11[visited.add(start_node.node_id)]
n12{while queue}
n13[current = queue.pop(0)]
n14[result.append(current)]
n15[next_nodes = graph.get_next_nodes...]
n16{for node in next_nodes}
n17{if node.node_id not in visited}
n18[visited.add(node.node_id)]
n19[queue.append(node)]
n20[]
n21[]
n22[]
n23{for node in graph.nodes.values()}
n24{if node.node_id not in visited}
n25[result.append(node)]
n26[]
n27[]
n28[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n22
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n21
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n16
n21 --> n12
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n27
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n23
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;拓撲排序\n\n Args:\n graph: 攻擊...]
n4[visited = set()]
n5[result = []]
n6[start_node = graph.get_start_node...]
n7{if not start_node}
n8[return list(graph.nodes.values())]
n9[]
n10[queue = [start_node]]
n11[visited.add(start_node.node_id)]
n12{while queue}
n13[current = queue.pop(0)]
n14[result.append(current)]
n15[next_nodes = graph.get_next_nodes...]
n16{for node in next_nodes}
n17{if node.node_id not in visited}
n18[visited.add(node.node_id)]
n19[queue.append(node)]
n20[]
n21[]
n22[]
n23{for node in graph.nodes.values()}
n24{if node.node_id not in visited}
n25[result.append(node)]
n26[]
n27[]
n28[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n22
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n21
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n16
n21 --> n12
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n27
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n23
n27 --> n28
n28 --> n2
401. core aiva core planner task converter Function add task
flowchart TB
n1([開始])
n2([結束])
n3['添加任務']
n4[self.tasks.append(task)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加任務&#39;]
n4[self.tasks.append(task)]
n1 --> n3
n3 --> n4
n4 --> n2
402. core aiva core planner task converter Function convert
flowchart TB
n1([開始])
n2([結束])
n3['將攻擊流程圖轉換為任務序列\n\n Args:\n ...]
n4[sequence = TaskSequence(sequenc...]
n5[sorted_nodes = self._topological_so...]
n6[node_to_task_id: dict[str, str] = {}]
n7{for node in sorted_nodes}
n8{if node.node_type in (NodeType...}
n9[continue]
n10[]
n11[task = self._create_task_fr...]
n12[dependencies = []]
n13{for edge in graph.edges}
n14{if edge.to_node == node.node_id}
n15[source_node_id = edge.from_node]
n16{if source_node_id in node_to_t...}
n17[dependencies.append(node_to_task_id[source_node_i...]
n18[]
n19[]
n20[]
n21[task.dependencies = dependencies]
n22[node_to_task_id[node.node_id] = task.task_id]
n23[sequence.add_task(task)]
n24[]
n25[logger.info(f"Converted graph '&...]
n26[return sequence]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n24
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n20
n14 -->|Yes| n15
n14 -->|No| n19
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n13
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n7
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將攻擊流程圖轉換為任務序列\n\n Args:\n ...]
n4[sequence = TaskSequence(sequenc...]
n5[sorted_nodes = self._topological_so...]
n6[node_to_task_id: dict[str, str] = {}]
n7{for node in sorted_nodes}
n8{if node.node_type in (NodeType...}
n9[continue]
n10[]
n11[task = self._create_task_fr...]
n12[dependencies = []]
n13{for edge in graph.edges}
n14{if edge.to_node == node.node_id}
n15[source_node_id = edge.from_node]
n16{if source_node_id in node_to_t...}
n17[dependencies.append(node_to_task_id[source_node_i...]
n18[]
n19[]
n20[]
n21[task.dependencies = dependencies]
n22[node_to_task_id[node.node_id] = task.task_id]
n23[sequence.add_task(task)]
n24[]
n25[logger.info(f&quot;Converted graph &#39;&...]
n26[return sequence]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n24
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n20
n14 -->|Yes| n15
n14 -->|No| n19
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n13
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n7
n24 --> n25
n25 --> n26
n26 --> n2
403. core aiva core planner task converter Function get pending tasks
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有待執行的任務']
n4[return [t for t in self.tasks if t.st...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有待執行的任務&#39;]
n4[return [t for t in self.tasks if t.st...]
n1 --> n3
n3 --> n4
n4 --> n2
404. core aiva core planner task converter Function get runnable tasks
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有可以立即執行的任務(依賴已滿足)']
n4[runnable = []]
n5{for task in self.tasks}
n6{if task.status != TaskStatus.P...}
n7[continue]
n8[]
n9[dependencies_met = True]
n10{for dep_id in task.dependencies}
n11[dep_task = self.get_task(dep_id...]
n12{if not dep_task or dep_task.st...}
n13[dependencies_met = False]
n14[break]
n15[]
n16[]
n17{if dependencies_met}
n18[runnable.append(task)]
n19[]
n20[]
n21[return runnable]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n20
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n16
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n5
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有可以立即執行的任務(依賴已滿足)&#39;]
n4[runnable = []]
n5{for task in self.tasks}
n6{if task.status != TaskStatus.P...}
n7[continue]
n8[]
n9[dependencies_met = True]
n10{for dep_id in task.dependencies}
n11[dep_task = self.get_task(dep_id...]
n12{if not dep_task or dep_task.st...}
n13[dependencies_met = False]
n14[break]
n15[]
n16[]
n17{if dependencies_met}
n18[runnable.append(task)]
n19[]
n20[]
n21[return runnable]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n20
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n16
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n5
n20 --> n21
n21 --> n2
405. core aiva core planner task converter Function get task
flowchart TB
n1([開始])
n2([結束])
n3['根據 ID 獲取任務']
n4{for task in self.tasks}
n5{if task.task_id == task_id}
n6[return task]
n7[]
n8[]
n9[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;根據 ID 獲取任務&#39;]
n4{for task in self.tasks}
n5{if task.task_id == task_id}
n6[return task]
n7[]
n8[]
n9[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
406. core aiva core planner tool selector Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化工具選擇器']
n4[self.task_service_map: dict[str, ServiceType] = &...]
n5[self.attack_function_map: dict[str, ServiceType] ...]
n6[logger.info('ToolSelector initialized wit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化工具選擇器&#39;]
n4[self.task_service_map: dict[str, ServiceType] = &...]
n5[self.attack_function_map: dict[str, ServiceType] ...]
n6[logger.info(&#39;ToolSelector initialized wit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
407. core aiva core planner tool selector Function repr
flowchart TB
n1([開始])
n2([結束])
n3[return f'ToolDecision({self.service_...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return f&#39;ToolDecision({self.service_...]
n1 --> n3
n3 --> n2
408. core aiva core planner tool selector Function determine endpoint and function
flowchart TB
n1([開始])
n2([結束])
n3['確定服務端點和函數\n\n Args:\n serv...]
n4[endpoint_map = {ServiceType.SCAN_SE...]
n5[return endpoint_map.get(service_type,...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;確定服務端點和函數\n\n Args:\n serv...]
n4[endpoint_map = {ServiceType.SCAN_SE...]
n5[return endpoint_map.get(service_type,...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
409. core aiva core planner tool selector Function determine routing key
flowchart TB
n1([開始])
n2([結束])
n3['確定 RabbitMQ routing key\n\n Args:\n ...]
n4[routing_key_map = {ServiceType.SCAN_SE...]
n5[return routing_key_map.get(service_ty...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;確定 RabbitMQ routing key\n\n Args:\n ...]
n4[routing_key_map = {ServiceType.SCAN_SE...]
n5[return routing_key_map.get(service_ty...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
410. core aiva core planner tool selector Function prepare parameters
flowchart TB
n1([開始])
n2([結束])
n3['準備傳遞給服務的參數\n\n Args:\n tas...]
n4[params = task.parameters.copy...]
n5[params['task_id'] = task....]
n6[params['task_type'] = tas...]
n7[params['action'] = task.a...]
n8[return params]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;準備傳遞給服務的參數\n\n Args:\n tas...]
n4[params = task.parameters.copy...]
n5[params[&#39;task_id&#39;] = task....]
n6[params[&#39;task_type&#39;] = tas...]
n7[params[&#39;action&#39;] = task.a...]
n8[return params]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
411. core aiva core planner tool selector Function select service type
flowchart TB
n1([開始])
n2([結束])
n3['選擇服務類型\n\n Args:\n task: 任...]
n4[attack_type = task.parameters.get(...]
n5{if attack_type and attack_type...}
n6[return self.attack_function_map[attac...]
n7[]
n8[return self.task_service_map.get(task...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;選擇服務類型\n\n Args:\n task: 任...]
n4[attack_type = task.parameters.get(...]
n5{if attack_type and attack_type...}
n6[return self.attack_function_map[attac...]
n7[]
n8[return self.task_service_map.get(task...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
412. core aiva core planner tool selector Function select tool
flowchart TB
n1([開始])
n2([結束])
n3['選擇執行任務的工具\n\n Args:\n task...]
n4[logger.debug(f'Selecting tool for task ...]
n5[service_type = self._select_service...]
n6[(endpoint, function) = self._determine_endp...]
n7[parameters = self._prepare_parame...]
n8[routing_key = self._determine_rout...]
n9[decision = ToolDecision(task_id...]
n10[logger.info(f'Selected {service_type...]
n11[return decision]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;選擇執行任務的工具\n\n Args:\n task...]
n4[logger.debug(f&#39;Selecting tool for task &#...]
n5[service_type = self._select_service...]
n6[(endpoint, function) = self._determine_endp...]
n7[parameters = self._prepare_parame...]
n8[routing_key = self._determine_rout...]
n9[decision = ToolDecision(task_id...]
n10[logger.info(f&#39;Selected {service_type...]
n11[return decision]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
413. core aiva core rag demo rag integration Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化\n\n Args:\n rag_engine...]
n4[self.rag_engine = rag_engine]
n5[self.ai_model_name = ai_model_name]
n6[logger.info(f'AIAgentWithRAG initialized ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化\n\n Args:\n rag_engine...]
n4[self.rag_engine = rag_engine]
n5[self.ai_model_name = ai_model_name]
n6[logger.info(f&#39;AIAgentWithRAG initialized ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
414. core aiva core rag demo rag integration Function build prompt with context
flowchart TB
n1([開始])
n2([結束])
n3['構建帶 RAG 上下文的提示詞\n\n Args:\n ...]
n4[prompt_parts = ['# Task: Generate a...]
n5{if context['similar_techniques...}
n6[prompt_parts.append('\n## Similar...]
n7{for tech in context['similar_...}
n8[prompt_parts.append(f"- {tech[&...]
n9[prompt_parts.append(f" {tech[&...]
n10[]
n11[]
n12{if context['successful_experie...}
n13[prompt_parts.append('\n## Success...]
n14{for exp in context['successf...}
n15[prompt_parts.append(f"- {exp[&&...]
n16[prompt_parts.append(f" {exp[&&...]
n17[]
n18[]
n19{if context['best_practices']}
n20[prompt_parts.append('\n## Best Pr...]
n21{for bp in context['best_pra...}
n22[prompt_parts.append(f"- {bp[&...]
n23[]
n24[]
n25[prompt_parts.append('\n## Instruc...]
n26[return '\n'.join(prompt_parts...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n7
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n18
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n14
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n21
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建帶 RAG 上下文的提示詞\n\n Args:\n ...]
n4[prompt_parts = [&#39;# Task: Generate a...]
n5{if context[&#39;similar_techniques&#3...}
n6[prompt_parts.append(&#39;\n## Similar...]
n7{for tech in context[&#39;similar_...}
n8[prompt_parts.append(f&quot;- {tech[&...]
n9[prompt_parts.append(f&quot; {tech[&...]
n10[]
n11[]
n12{if context[&#39;successful_experie...}
n13[prompt_parts.append(&#39;\n## Success...]
n14{for exp in context[&#39;successf...}
n15[prompt_parts.append(f&quot;- {exp[&&...]
n16[prompt_parts.append(f&quot; {exp[&&...]
n17[]
n18[]
n19{if context[&#39;best_practices&#39;]}
n20[prompt_parts.append(&#39;\n## Best Pr...]
n21{for bp in context[&#39;best_pra...}
n22[prompt_parts.append(f&quot;- {bp[&&#...]
n23[]
n24[]
n25[prompt_parts.append(&#39;\n## Instruc...]
n26[return &#39;\n&#39;.join(prompt_parts...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n7
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n18
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n14
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n21
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
415. core aiva core rag knowledge base Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化知識庫\n\n Args:\n vector_...]
n4[self.vector_store = vector_store or Vect...]
n5[self.data_directory = data_directory or Pa...]
n6[self.data_directory.mkdir(parents=True, exist_ok=T...]
n7[self.entries: dict[str, KnowledgeEntry] = {&...]
n8[self._load_knowledge_base()]
n9[logger.info(f'KnowledgeBase initialized w...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化知識庫\n\n Args:\n vector_...]
n4[self.vector_store = vector_store or Vect...]
n5[self.data_directory = data_directory or Pa...]
n6[self.data_directory.mkdir(parents=True, exist_ok=T...]
n7[self.entries: dict[str, KnowledgeEntry] = {&...]
n8[self._load_knowledge_base()]
n9[logger.info(f&#39;KnowledgeBase initialized w...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
416. core aiva core rag knowledge base Function load knowledge base
flowchart TB
n1([開始])
n2([結束])
n3['從磁盤加載知識庫']
n4[entries_file = self.data_directory ...]
n5{if entries_file.exists()}
n6[with open(entr...]
n7[entries_data = json.load(f)]
n8{for entry_data in entries_data}
n9[entry = KnowledgeEntry.from_...]
n10[self.entries[entry.id] = entry]
n11[]
n12[]
n13[self.vector_store.load(self.data_directory / &...]
n14[logger.info(f'Loaded {len(self.e...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n8
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從磁盤加載知識庫&#39;]
n4[entries_file = self.data_directory ...]
n5{if entries_file.exists()}
n6[with open(entr...]
n7[entries_data = json.load(f)]
n8{for entry_data in entries_data}
n9[entry = KnowledgeEntry.from_...]
n10[self.entries[entry.id] = entry]
n11[]
n12[]
n13[self.vector_store.load(self.data_directory / &...]
n14[logger.info(f&#39;Loaded {len(self.e...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n8
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
417. core aiva core rag knowledge base Function add attack plan
flowchart TB
n1([開始])
n2([結束])
n3['添加攻擊計畫到知識庫\n\n Args:\n pla...]
n4[entry_id = plan_id or f"plan_{p...]
n5[steps_text = '\n'.join([f...]
n6[content = f"\nTarget: {plan.ta...]
n7[self.add_entry(entry_id=entry_id, entry_type=Knowl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加攻擊計畫到知識庫\n\n Args:\n pla...]
n4[entry_id = plan_id or f&quot;plan_{p...]
n5[steps_text = &#39;\n&#39;.join([f...]
n6[content = f&quot;\nTarget: {plan.ta...]
n7[self.add_entry(entry_id=entry_id, entry_type=Knowl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
418. core aiva core rag knowledge base Function add entry
flowchart TB
n1([開始])
n2([結束])
n3['添加知識條目\n\n Args:\n entry_i...]
n4[entry = KnowledgeEntry(id=en...]
n5[self.entries[entry_id] = entry]
n6[searchable_text = f"{title}\n{con...]
n7[self.vector_store.add_document(doc_id=entry_id, te...]
n8[logger.info(f'Added knowledge entry: ...]
n9[return entry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加知識條目\n\n Args:\n entry_i...]
n4[entry = KnowledgeEntry(id=en...]
n5[self.entries[entry_id] = entry]
n6[searchable_text = f&quot;{title}\n{con...]
n7[self.vector_store.add_document(doc_id=entry_id, te...]
n8[logger.info(f&#39;Added knowledge entry: ...]
n9[return entry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
419. core aiva core rag knowledge base Function add experience sample
flowchart TB
n1([開始])
n2([結束])
n3['添加經驗樣本到知識庫\n\n Args:\n sam...]
n4[entry_id = f'exp_{sample.sessio...]
n5[content = f'\nTarget: {sample....]
n6[self.add_entry(entry_id=entry_id, entry_type=Knowl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加經驗樣本到知識庫\n\n Args:\n sam...]
n4[entry_id = f&#39;exp_{sample.sessio...]
n5[content = f&#39;\nTarget: {sample....]
n6[self.add_entry(entry_id=entry_id, entry_type=Knowl...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
420. core aiva core rag knowledge base Function from dict
flowchart TB
n1([開始])
n2([結束])
n3['從字典創建']
n4[return cls(id=data['id'...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從字典創建&#39;]
n4[return cls(id=data[&#39;id&#39;&#...]
n1 --> n3
n3 --> n4
n4 --> n2
421. core aiva core rag knowledge base Function get entry
flowchart TB
n1([開始])
n2([結束])
n3['獲取知識條目\n\n Args:\n entry_i...]
n4[return self.entries.get(entry_id)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取知識條目\n\n Args:\n entry_i...]
n4[return self.entries.get(entry_id)]
n1 --> n3
n3 --> n4
n4 --> n2
422. core aiva core rag knowledge base Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取知識庫統計信息\n\n Returns:\n 統...]
n4[stats_by_type = {}]
n5{for entry in self.entries.valu...}
n6[type_name = entry.type.value]
n7{if type_name not in stats_by_type}
n8[stats_by_type[type_name] = {'cou...]
n9[]
n10[stats_by_type[type_name]['count&a...]
n11[stats_by_type[type_name]['total_u...]
n12[stats_by_type[type_name]['avg_suc...]
n13[]
n14{for stats in stats_by_type.val...}
n15{if stats['count'] > 0}
n16[stats['avg_success_rate']...]
n17[]
n18[]
n19[return {'total_entries': len...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n5
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n18
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n14
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取知識庫統計信息\n\n Returns:\n 統...]
n4[stats_by_type = {}]
n5{for entry in self.entries.valu...}
n6[type_name = entry.type.value]
n7{if type_name not in stats_by_type}
n8[stats_by_type[type_name] = {&#39;cou...]
n9[]
n10[stats_by_type[type_name][&#39;count&a...]
n11[stats_by_type[type_name][&#39;total_u...]
n12[stats_by_type[type_name][&#39;avg_suc...]
n13[]
n14{for stats in stats_by_type.val...}
n15{if stats[&#39;count&#39;] &gt; 0}
n16[stats[&#39;avg_success_rate&#39;]...]
n17[]
n18[]
n19[return {&#39;total_entries&#39;: len...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n5
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n18
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n14
n18 --> n19
n19 --> n2
423. core aiva core rag knowledge base Function get top entries
flowchart TB
n1([開始])
n2([結束])
n3['獲取排名最高的知識條目\n\n Args:\n en...]
n4[filtered_entries = [entry for entry in ...]
n5[sorted_entries = sorted(filtered_entr...]
n6[return sorted_entries[:top_k]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取排名最高的知識條目\n\n Args:\n en...]
n4[filtered_entries = [entry for entry in ...]
n5[sorted_entries = sorted(filtered_entr...]
n6[return sorted_entries[:top_k]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
424. core aiva core rag knowledge base Function save knowledge base
flowchart TB
n1([開始])
n2([結束])
n3['保存知識庫到磁盤']
n4[entries_file = self.data_directory ...]
n5[with open(entr...]
n6[entries_data = [entry.to_dict() for...]
n7[json.dump(entries_data, f, indent=2)]
n8[self.vector_store.save(self.data_directory / &...]
n9[logger.info(f'Saved {len(self.en...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存知識庫到磁盤&#39;]
n4[entries_file = self.data_directory ...]
n5[with open(entr...]
n6[entries_data = [entry.to_dict() for...]
n7[json.dump(entries_data, f, indent=2)]
n8[self.vector_store.save(self.data_directory / &...]
n9[logger.info(f&#39;Saved {len(self.en...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
425. core aiva core rag knowledge base Function search
flowchart TB
n1([開始])
n2([結束])
n3['搜索知識條目\n\n Args:\n query: ...]
n4[filter_metadata: dict[str, Any] = {}]
n5{if entry_type}
n6[filter_metadata['type'] =...]
n7[]
n8[search_results = self.vector_store.se...]
n9[filtered_results = []]
n10{for result in search_results}
n11[entry = self.entries.get(res...]
n12{if entry is None}
n13[continue]
n14[]
n15{if tags and (not any((tag in e...}
n16[continue]
n17[]
n18[filtered_results.append(entry)]
n19{if len(filtered_results) >= top_k}
n20[break]
n21[]
n22[]
n23[logger.debug(f"Search for '{...]
n24[return filtered_results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n22
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n10
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;搜索知識條目\n\n Args:\n query: ...]
n4[filter_metadata: dict[str, Any] = {}]
n5{if entry_type}
n6[filter_metadata[&#39;type&#39;] =...]
n7[]
n8[search_results = self.vector_store.se...]
n9[filtered_results = []]
n10{for result in search_results}
n11[entry = self.entries.get(res...]
n12{if entry is None}
n13[continue]
n14[]
n15{if tags and (not any((tag in e...}
n16[continue]
n17[]
n18[filtered_results.append(entry)]
n19{if len(filtered_results) &gt;= top_k}
n20[break]
n21[]
n22[]
n23[logger.debug(f&quot;Search for &#39;{...]
n24[return filtered_results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n22
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n10
n22 --> n23
n23 --> n24
n24 --> n2
426. core aiva core rag knowledge base Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典']
n4[return {'id': self.id, &...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典&#39;]
n4[return {&#39;id&#39;: self.id, &...]
n1 --> n3
n3 --> n4
n4 --> n2
427. core aiva core rag knowledge base Function update usage stats
flowchart TB
n1([開始])
n2([結束])
n3['更新知識條目使用統計\n\n Args:\n ent...]
n4[entry = self.entries.get(ent...]
n5{if entry is None}
n6[return]
n7[]
n8[entry.usage_count += 1]
n9[entry.updated_at = datetime.now()]
n10[alpha = 0.1]
n11[success_value = 1.0 if success else ...]
n12[entry.success_rate = alpha * success_valu...]
n13[logger.debug(f'Updated usage stats for ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新知識條目使用統計\n\n Args:\n ent...]
n4[entry = self.entries.get(ent...]
n5{if entry is None}
n6[return]
n7[]
n8[entry.usage_count += 1]
n9[entry.updated_at = datetime.now()]
n10[alpha = 0.1]
n11[success_value = 1.0 if success else ...]
n12[entry.success_rate = alpha * success_valu...]
n13[logger.debug(f&#39;Updated usage stats for &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
428. core aiva core rag rag engine Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 RAG 引擎\n\n Args:\n kno...]
n4[self.knowledge_base = knowledge_base]
n5[logger.info('RAG Engine initialized&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 RAG 引擎\n\n Args:\n kno...]
n4[self.knowledge_base = knowledge_base]
n5[logger.info(&#39;RAG Engine initialized&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
429. core aiva core rag rag engine Function extract successful pattern
flowchart TB
n1([開始])
n2([結束])
n3['提取成功模式\n\n Args:\n sample:...]
n4[payload = sample.action.parame...]
n5{if payload}
n6[entry_id = f'payload_{sample.st...]
n7[self.knowledge_base.add_entry(entry_id=entry_id, e...]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取成功模式\n\n Args:\n sample:...]
n4[payload = sample.action.parame...]
n5{if payload}
n6[entry_id = f&#39;payload_{sample.st...]
n7[self.knowledge_base.add_entry(entry_id=entry_id, e...]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n2
430. core aiva core rag rag engine Function analyze failure
flowchart TB
n1([開始])
n2([結束])
n3['分析失敗原因並建議修正\n\n Args:\n fa...]
n4[query = f'{failed_step.tool}...]
n5[similar_failures = self.knowledge_base....]
n6[mitigations = self.knowledge_base....]
n7[context = {'failed_step': ...]
n8[logger.info(f'Analyzed failure for {...]
n9[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析失敗原因並建議修正\n\n Args:\n fa...]
n4[query = f&#39;{failed_step.tool}...]
n5[similar_failures = self.knowledge_base....]
n6[mitigations = self.knowledge_base....]
n7[context = {&#39;failed_step&#39;: &#...]
n8[logger.info(f&#39;Analyzed failure for {...]
n9[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
431. core aiva core rag rag engine Function enhance attack plan
flowchart TB
n1([開始])
n2([結束])
n3['增強攻擊計畫\n\n 使用 RAG 檢索相關經驗和技術,增強計畫生成\n\...]
n4[query = f'{objective} {targe...]
n5[attack_techniques = self.knowledge_base....]
n6[successful_experiences = self.knowledge_base....]
n7[best_practices = self.knowledge_base....]
n8[context = {'target': {&...]
n9[logger.info(f'Enhanced attack plan with &...]
n10[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;增強攻擊計畫\n\n 使用 RAG 檢索相關經驗和技術,增強計畫生成\n\...]
n4[query = f&#39;{objective} {targe...]
n5[attack_techniques = self.knowledge_base....]
n6[successful_experiences = self.knowledge_base....]
n7[best_practices = self.knowledge_base....]
n8[context = {&#39;target&#39;: {&...]
n9[logger.info(f&#39;Enhanced attack plan with &...]
n10[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
432. core aiva core rag rag engine Function get relevant payloads
flowchart TB
n1([開始])
n2([結束])
n3['獲取相關有效載荷\n\n Args:\n vulne...]
n4[target_desc = ' '.join([t...]
n5[query = f'{vulnerability_typ...]
n6[payloads = self.knowledge_base....]
n7[sorted_payloads = sorted(payloads, key...]
n8[results = [{'payload': e...]
n9[logger.info(f'Retrieved {len(res...]
n10[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取相關有效載荷\n\n Args:\n vulne...]
n4[target_desc = &#39; &#39;.join([t...]
n5[query = f&#39;{vulnerability_typ...]
n6[payloads = self.knowledge_base....]
n7[sorted_payloads = sorted(payloads, key...]
n8[results = [{&#39;payload&#39;: e...]
n9[logger.info(f&#39;Retrieved {len(res...]
n10[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
433. core aiva core rag rag engine Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取 RAG 引擎統計信息\n\n Returns:\n ...]
n4[return {'knowledge_base': se...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取 RAG 引擎統計信息\n\n Returns:\n ...]
n4[return {&#39;knowledge_base&#39;: se...]
n1 --> n3
n3 --> n4
n4 --> n2
434. core aiva core rag rag engine Function learn from experience
flowchart TB
n1([開始])
n2([結束])
n3['從經驗樣本學習\n\n 將成功或失敗的經驗添加到知識庫\n\n ...]
n4[self.knowledge_base.add_experience_sample(sample)]
n5{if sample.reward.success and s...}
n6[self._extract_successful_pattern(sample)]
n7[]
n8[logger.info(f'Learned from experience: se...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從經驗樣本學習\n\n 將成功或失敗的經驗添加到知識庫\n\n ...]
n4[self.knowledge_base.add_experience_sample(sample)]
n5{if sample.reward.success and s...}
n6[self._extract_successful_pattern(sample)]
n7[]
n8[logger.info(f&#39;Learned from experience: se...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
435. core aiva core rag rag engine Function save knowledge
flowchart TB
n1([開始])
n2([結束])
n3['保存知識庫']
n4[self.knowledge_base.save_knowledge_base()]
n5[logger.info('Knowledge base saved&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存知識庫&#39;]
n4[self.knowledge_base.save_knowledge_base()]
n5[logger.info(&#39;Knowledge base saved&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
436. core aiva core rag rag engine Function suggest next step
flowchart TB
n1([開始])
n2([結束])
n3['建議下一步驟\n\n 基於當前狀態和歷史步驟,使用 RAG 建議最佳下一步...]
n4[steps_summary = ' -> '.joi...]
n5[query = f"{current_state.get...]
n6[similar_experiences = self.knowledge_base....]
n7[tool_suggestions: dict[str, int] = {}]
n8{for entry in similar_experiences}
n9[metadata = entry.metadata]
n10[next_tool = metadata.get('next_t...]
n11{if next_tool}
n12[tool_suggestions[next_tool] = tool_suggestions.ge...]
n13[]
n14[]
n15[sorted_suggestions = sorted(tool_suggesti...]
n16[context = {'current_state': ...]
n17[logger.info(f'Generated step suggestions ...]
n18[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;建議下一步驟\n\n 基於當前狀態和歷史步驟,使用 RAG 建議最佳下一步...]
n4[steps_summary = &#39; -&gt; &#39;.joi...]
n5[query = f&quot;{current_state.get...]
n6[similar_experiences = self.knowledge_base....]
n7[tool_suggestions: dict[str, int] = {}]
n8{for entry in similar_experiences}
n9[metadata = entry.metadata]
n10[next_tool = metadata.get(&#39;next_t...]
n11{if next_tool}
n12[tool_suggestions[next_tool] = tool_suggestions.ge...]
n13[]
n14[]
n15[sorted_suggestions = sorted(tool_suggesti...]
n16[context = {&#39;current_state&#39;: ...]
n17[logger.info(f&#39;Generated step suggestions ...]
n18[return context]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
437. core aiva core rag vector store Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化向量存儲\n\n Args:\n backen...]
n4[self.backend = backend]
n5[self.persist_directory = persist_directory or...]
n6[self.embedding_model_name = embedding_model]
n7[self.vectors: dict[str, np.ndarray] = {}]
n8[self.metadata: dict[str, dict[str, Any]] ...]
n9[self.documents: dict[str, str] = {}]
n10[self._embedding_model: Any | None = None]
n11[self._initialize_backend()]
n12[logger.info(f'VectorStore initialized wit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化向量存儲\n\n Args:\n backen...]
n4[self.backend = backend]
n5[self.persist_directory = persist_directory or...]
n6[self.embedding_model_name = embedding_model]
n7[self.vectors: dict[str, np.ndarray] = {}]
n8[self.metadata: dict[str, dict[str, Any]] ...]
n9[self.documents: dict[str, str] = {}]
n10[self._embedding_model: Any | None = None]
n11[self._initialize_backend()]
n12[logger.info(f&#39;VectorStore initialized wit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
438. core aiva core rag vector store Function get embedding model
flowchart TB
n1([開始])
n2([結束])
n3['獲取嵌入模型(延遲加載)']
n4{if self._embedding_model is None}
n5[try]
n6[from sentence_transformers import SentenceTransfor...]
n7[self._embedding_model = SentenceTransformer(...]
n8[logger.info(f'Loaded embedding model: ...]
n9[]
n10[except ImportError]
n11[logger.warning('sentence-transformers not...]
n12[self._embedding_model = self._simple_embeddi...]
n13[]
n14[return self._embedding_model]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n13
n5 --> n6
n5 --> n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n13
n10 --> n11
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取嵌入模型(延遲加載)&#39;]
n4{if self._embedding_model is None}
n5[try]
n6[from sentence_transformers import SentenceTransfor...]
n7[self._embedding_model = SentenceTransformer(...]
n8[logger.info(f&#39;Loaded embedding model: ...]
n9[]
n10[except ImportError]
n11[logger.warning(&#39;sentence-transformers not...]
n12[self._embedding_model = self._simple_embeddi...]
n13[]
n14[return self._embedding_model]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n13
n5 --> n6
n5 --> n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n13
n10 --> n11
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n2
439. core aiva core rag vector store Function initialize backend
flowchart TB
n1([開始])
n2([結束])
n3['初始化後端存儲']
n4{if self.backend == 'memory'}
n5[logger.info('Using in-memory vector store...]
n6{if self.backend == 'chroma'}
n7[try]
n8[import chromadb]
n9[self.persist_directory.mkdir(parents=True, exist_o...]
n10[self.client = chromadb.PersistentC...]
n11[logger.info(f'ChromaDB initialized at ...]
n12[]
n13[except ImportError]
n14[logger.warning('ChromaDB not installed, f...]
n15[self.backend = 'memory']
n16{if self.backend == 'faiss'}
n17[try]
n18[import faiss]
n19[self.persist_directory.mkdir(parents=True, exist_o...]
n20[self.index = None]
n21[logger.info('FAISS backend initialized&am...]
n22[]
n23[except ImportError]
n24[logger.warning('FAISS not installed, fall...]
n25[self.backend = 'memory']
n26[]
n27[]
n28[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n28
n6 -->|Yes| n7
n6 -->|No| n16
n7 --> n8
n7 --> n13
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n27
n13 --> n14
n14 --> n15
n15 --> n12
n16 -->|Yes| n17
n16 -->|No| n26
n17 --> n18
n17 --> n23
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n26
n23 --> n24
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化後端存儲&#39;]
n4{if self.backend == &#39;memory&#39;}
n5[logger.info(&#39;Using in-memory vector store...]
n6{if self.backend == &#39;chroma&#39;}
n7[try]
n8[import chromadb]
n9[self.persist_directory.mkdir(parents=True, exist_o...]
n10[self.client = chromadb.PersistentC...]
n11[logger.info(f&#39;ChromaDB initialized at ...]
n12[]
n13[except ImportError]
n14[logger.warning(&#39;ChromaDB not installed, f...]
n15[self.backend = &#39;memory&#39;]
n16{if self.backend == &#39;faiss&#39;}
n17[try]
n18[import faiss]
n19[self.persist_directory.mkdir(parents=True, exist_o...]
n20[self.index = None]
n21[logger.info(&#39;FAISS backend initialized&am...]
n22[]
n23[except ImportError]
n24[logger.warning(&#39;FAISS not installed, fall...]
n25[self.backend = &#39;memory&#39;]
n26[]
n27[]
n28[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n28
n6 -->|Yes| n7
n6 -->|No| n16
n7 --> n8
n7 --> n13
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n27
n13 --> n14
n14 --> n15
n15 --> n12
n16 -->|Yes| n17
n16 -->|No| n26
n17 --> n18
n17 --> n23
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n26
n23 --> n24
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n28
n28 --> n2
440. core aiva core rag vector store Function simple embedding
flowchart TB
n1([開始])
n2([結束])
n3['簡單的嵌入函數(後備方案)\n\n Args:\n ...]
n4[hash_val = hash(text)]
n5[dim = 384]
n6[np.random.seed(hash_val % 2 ** 32)]
n7[embedding = np.random.randn(dim)...]
n8[norm = np.linalg.norm(embed...]
n9{if norm > 0}
n10[embedding = embedding / norm]
n11[]
n12[return embedding]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;簡單的嵌入函數(後備方案)\n\n Args:\n ...]
n4[hash_val = hash(text)]
n5[dim = 384]
n6[np.random.seed(hash_val % 2 ** 32)]
n7[embedding = np.random.randn(dim)...]
n8[norm = np.linalg.norm(embed...]
n9{if norm &gt; 0}
n10[embedding = embedding / norm]
n11[]
n12[return embedding]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
441. core aiva core rag vector store Function add batch
flowchart TB
n1([開始])
n2([結束])
n3['批量添加文檔\n\n Args:\n doc_ids...]
n4{if metadatas is None}
n5[metadatas = [{}] * len(doc_ids)]
n6[]
n7{for (doc_id, text, metadata) in zip(doc_ids, ...}
n8[self.add_document(doc_id, text, metadata)]
n9[]
n10[logger.info(f'Added {len(doc_ids...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;批量添加文檔\n\n Args:\n doc_ids...]
n4{if metadatas is None}
n5[metadatas = [{}] * len(doc_ids)]
n6[]
n7{for (doc_id, text, metadata) in zip(doc_ids, ...}
n8[self.add_document(doc_id, text, metadata)]
n9[]
n10[logger.info(f&#39;Added {len(doc_ids...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n2
442. core aiva core rag vector store Function add document
flowchart TB
n1([開始])
n2([結束])
n3['添加文檔到向量存儲\n\n Args:\n doc_...]
n4[model = self._get_embedding_...]
n5{if callable(model)}
n6[embedding = model(text)]
n7[embedding = model.encode(text, c...]
n8[]
n9[self.vectors[doc_id] = embedding]
n10[self.documents[doc_id] = text]
n11[self.metadata[doc_id] = metadata or {}]
n12[logger.debug(f'Added document {doc_i...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加文檔到向量存儲\n\n Args:\n doc_...]
n4[model = self._get_embedding_...]
n5{if callable(model)}
n6[embedding = model(text)]
n7[embedding = model.encode(text, c...]
n8[]
n9[self.vectors[doc_id] = embedding]
n10[self.documents[doc_id] = text]
n11[self.metadata[doc_id] = metadata or {}]
n12[logger.debug(f&#39;Added document {doc_i...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
443. core aiva core rag vector store Function delete document
flowchart TB
n1([開始])
n2([結束])
n3['刪除文檔\n\n Args:\n doc_id: 文...]
n4{if doc_id in self.vectors}
n5[del self.vectors[doc_id]]
n6[del self.documents[doc_id]]
n7[del self.metadata[doc_id]]
n8[logger.debug(f'Deleted document {doc...]
n9[return True]
n10[]
n11[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;刪除文檔\n\n Args:\n doc_id: 文...]
n4{if doc_id in self.vectors}
n5[del self.vectors[doc_id]]
n6[del self.documents[doc_id]]
n7[del self.metadata[doc_id]]
n8[logger.debug(f&#39;Deleted document {doc...]
n9[return True]
n10[]
n11[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
444. core aiva core rag vector store Function get document
flowchart TB
n1([開始])
n2([結束])
n3['獲取文檔\n\n Args:\n doc_id: 文...]
n4{if doc_id in self.vectors}
n5[return {'doc_id': doc_id, &a...]
n6[]
n7[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取文檔\n\n Args:\n doc_id: 文...]
n4{if doc_id in self.vectors}
n5[return {&#39;doc_id&#39;: doc_id, &a...]
n6[]
n7[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
445. core aiva core rag vector store Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計信息\n\n Returns:\n 統計信息...]
n4[return {'total_documents': l...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計信息\n\n Returns:\n 統計信息...]
n4[return {&#39;total_documents&#39;: l...]
n1 --> n3
n3 --> n4
n4 --> n2
446. core aiva core rag vector store Function load
flowchart TB
n1([開始])
n2([結束])
n3['從磁盤加載向量存儲\n\n Args:\n path...]
n4[load_path = path or self.persist...]
n5[vectors_file = load_path / 'vectors...]
n6{if vectors_file.exists()}
n7[self.vectors = np.load(vectors_file...]
n8[]
n9[data_file = load_path / 'data.js...]
n10{if data_file.exists()}
n11[with open(data...]
n12[data = json.load(f)]
n13[self.documents = data.get('documents&...]
n14[self.metadata = data.get('metadata&...]
n15[]
n16[logger.info(f'Loaded {len(self.v...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n15
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從磁盤加載向量存儲\n\n Args:\n path...]
n4[load_path = path or self.persist...]
n5[vectors_file = load_path / &#39;vectors...]
n6{if vectors_file.exists()}
n7[self.vectors = np.load(vectors_file...]
n8[]
n9[data_file = load_path / &#39;data.js...]
n10{if data_file.exists()}
n11[with open(data...]
n12[data = json.load(f)]
n13[self.documents = data.get(&#39;documents&...]
n14[self.metadata = data.get(&#39;metadata&&#...]
n15[]
n16[logger.info(f&#39;Loaded {len(self.v...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n15
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
447. core aiva core rag vector store Function save
flowchart TB
n1([開始])
n2([結束])
n3['保存向量存儲到磁盤\n\n Args:\n path...]
n4[save_path = path or self.persist...]
n5[save_path.mkdir(parents=True, exist_ok=True)]
n6[vectors_file = save_path / 'vectors...]
n7[np.save(vectors_file, self.vectors)]
n8[data_file = save_path / 'data.js...]
n9[with open(data...]
n10[json.dump({'documents': ...]
n11[logger.info(f'Vector store saved to {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存向量存儲到磁盤\n\n Args:\n path...]
n4[save_path = path or self.persist...]
n5[save_path.mkdir(parents=True, exist_ok=True)]
n6[vectors_file = save_path / &#39;vectors...]
n7[np.save(vectors_file, self.vectors)]
n8[data_file = save_path / &#39;data.js...]
n9[with open(data...]
n10[json.dump({&#39;documents&#39;: ...]
n11[logger.info(f&#39;Vector store saved to {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
448. core aiva core rag vector store Function search
flowchart TB
n1([開始])
n2([結束])
n3['搜索相似文檔\n\n Args:\n query: ...]
n4[model = self._get_embedding_...]
n5{if callable(model)}
n6[query_embedding = model(query)]
n7[query_embedding = model.encode(query, ...]
n8[]
n9[similarities = []]
n10{for (doc_id, doc_embedding) in self.vectors.items...}
n11{if filter_metadata}
n12[doc_meta = self.metadata.get(do...]
n13{if not all((doc_meta.get(k) ==...}
n14[continue]
n15[]
n16[]
n17[similarity = np.dot(query_embeddi...]
n18[similarities.append({'doc_id&...]
n19[]
n20[similarities.sort(key=lambda x: float(x.get(&...]
n21[return similarities[:top_k]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n19
n11 -->|Yes| n12
n11 -->|No| n16
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n10
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;搜索相似文檔\n\n Args:\n query: ...]
n4[model = self._get_embedding_...]
n5{if callable(model)}
n6[query_embedding = model(query)]
n7[query_embedding = model.encode(query, ...]
n8[]
n9[similarities = []]
n10{for (doc_id, doc_embedding) in self.vectors.items...}
n11{if filter_metadata}
n12[doc_meta = self.metadata.get(do...]
n13{if not all((doc_meta.get(k) ==...}
n14[continue]
n15[]
n16[]
n17[similarity = np.dot(query_embeddi...]
n18[similarities.append({&#39;doc_id&...]
n19[]
n20[similarities.sort(key=lambda x: float(x.get(&...]
n21[return similarities[:top_k]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n19
n11 -->|Yes| n12
n11 -->|No| n16
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n10
n19 --> n20
n20 --> n21
n21 --> n2
449. core aiva core schemas Function all tasks
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有任務的平面列表']
n4[return self.xss_tasks + self.sqli_tas...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有任務的平面列表&#39;]
n4[return self.xss_tasks + self.sqli_tas...]
n1 --> n3
n3 --> n4
n4 --> n2
450. core aiva core schemas Function total candidates
flowchart TB
n1([開始])
n2([結束])
n3['總候選數量']
n4[return len(self.xss_candidates) + len...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;總候選數量&#39;]
n4[return len(self.xss_candidates) + len...]
n1 --> n3
n3 --> n4
n4 --> n2
451. core aiva core schemas Function total tasks
flowchart TB
n1([開始])
n2([結束])
n3['總任務數量']
n4[return len(self.xss_tasks) + len(self...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;總任務數量&#39;]
n4[return len(self.xss_tasks) + len(self...]
n1 --> n3
n3 --> n4
n4 --> n2
452. core aiva core schemas Function validate confidence
flowchart TB
n1([開始])
n2([結束])
n3['驗證置信度範圍']
n4{if not 0.0 <= v <= 1.0}
n5[raise ValueError('Confidence must be betw...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證置信度範圍&#39;]
n4{if not 0.0 &lt;= v &lt;= 1.0}
n5[raise ValueError(&#39;Confidence must be betw...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
453. core aiva core schemas Function validate risk score
flowchart TB
n1([開始])
n2([結束])
n3['驗證風險評分範圍']
n4{if not 0 <= v <= 100}
n5[raise ValueError('Risk score must be betw...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證風險評分範圍&#39;]
n4{if not 0 &lt;= v &lt;= 100}
n5[raise ValueError(&#39;Risk score must be betw...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
454. core aiva core state session state manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._scans: dict[str, ScanCompletedPayload] = ...]
n4[self._tasks: dict[str, TaskUpdatePayload] = {...]
n5[self._sessions: dict[str, dict[str, Any]]...]
n6[self._session_history: dict[str, list[dict[st...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._scans: dict[str, ScanCompletedPayload] = &#...]
n4[self._tasks: dict[str, TaskUpdatePayload] = {...]
n5[self._sessions: dict[str, dict[str, Any]]...]
n6[self._session_history: dict[str, list[dict[st...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
455. core aiva core state session state manager Function get session context
flowchart TB
n1([開始])
n2([結束])
n3['獲取會話上下文資訊,用於策略調整']
n4[session = self._sessions.get(s...]
n5[history = self._session_histor...]
n6[return {'scan_id': scan_id, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取會話上下文資訊,用於策略調整&#39;]
n4[session = self._sessions.get(s...]
n5[history = self._session_histor...]
n6[return {&#39;scan_id&#39;: scan_id, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
456. core aiva core state session state manager Function get session status
flowchart TB
n1([開始])
n2([結束])
n3['獲取會話狀態摘要']
n4[session = self._sessions.get(s...]
n5[return {'scan_id': scan_id, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取會話狀態摘要&#39;]
n4[session = self._sessions.get(s...]
n5[return {&#39;scan_id&#39;: scan_id, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
457. core aiva core state session state manager Function update context
flowchart TB
n1([開始])
n2([結束])
n3['更新會話上下文資料']
n4{if scan_id not in self._sessions}
n5[self._sessions[scan_id] = {'crea...]
n6[self._session_history[scan_id] = []]
n7[]
n8[self._sessions[scan_id].update(context_data)]
n9[self._sessions[scan_id]['updated_...]
n10[logger.debug(f'Updated context for sessio...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新會話上下文資料&#39;]
n4{if scan_id not in self._sessions}
n5[self._sessions[scan_id] = {&#39;crea...]
n6[self._session_history[scan_id] = []]
n7[]
n8[self._sessions[scan_id].update(context_data)]
n9[self._sessions[scan_id][&#39;updated_...]
n10[logger.debug(f&#39;Updated context for sessio...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
458. core aiva core state session state manager Function update session status
flowchart TB
n1([開始])
n2([結束])
n3['更新會話狀態']
n4{if session_id not in self._ses...}
n5[self._sessions[session_id] = {'c...]
n6[self._session_history[session_id] = []]
n7[]
n8[self._sessions[session_id]['statu...]
n9[self._sessions[session_id]['updat...]
n10{if additional_data}
n11[self._sessions[session_id].update(additional_...]
n12[]
n13[self._session_history[session_id].append(...]
n14[logger.info(f'Updated session {sessi...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新會話狀態&#39;]
n4{if session_id not in self._ses...}
n5[self._sessions[session_id] = {&#39;c...]
n6[self._session_history[session_id] = []]
n7[]
n8[self._sessions[session_id][&#39;statu...]
n9[self._sessions[session_id][&#39;updat...]
n10{if additional_data}
n11[self._sessions[session_id].update(additional_...]
n12[]
n13[self._session_history[session_id].append(...]
n14[logger.info(f&#39;Updated session {sessi...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
459. core aiva core storage backends Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.db_backend = db_backend]
n4[self.jsonl_backend = jsonl_backend or JSO...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.db_backend = db_backend]
n4[self.jsonl_backend = jsonl_backend or JSO...]
n1 --> n3
n3 --> n4
n4 --> n2
460. core aiva core storage config Function get storage config
flowchart TB
n1([開始])
n2([結束])
n3['獲取存儲配置']
n4[return {'data_root': str(...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取存儲配置&#39;]
n4[return {&#39;data_root&#39;: str(...]
n1 --> n3
n3 --> n4
n4 --> n2
461. core aiva core storage storage manager Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化存儲管理器\n\n Args:\n ...]
n4[self.data_root = Path(data_root)]
n5[self.db_type = db_type]
n6[self.db_config = db_config or {}]
n7[self.dirs: dict[str, Any] = {'tr...]
n8{if auto_create_dirs}
n9[self.initialize()]
n10[]
n11[self.backend = self._create_backend...]
n12[logger.info(f'StorageManager initialized:...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化存儲管理器\n\n Args:\n ...]
n4[self.data_root = Path(data_root)]
n5[self.db_type = db_type]
n6[self.db_config = db_config or {}]
n7[self.dirs: dict[str, Any] = {&#39;tr...]
n8{if auto_create_dirs}
n9[self.initialize()]
n10[]
n11[self.backend = self._create_backend...]
n12[logger.info(f&#39;StorageManager initialized:...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
462. core aiva core storage storage manager Function create backend
flowchart TB
n1([開始])
n2([結束])
n3['創建存儲後端']
n4{if self.db_type == 'sqlite'}
n5[db_path = self.db_config.get('...]
n6[return SQLiteBackend(db_path=db_path)]
n7{if self.db_type == 'postgres'}
n8[return PostgreSQLBackend(host=self.db...]
n9{if self.db_type == 'jsonl'}
n10[experiences_dir = self.db_config.get('...]
n11[return JSONLBackend(data_dir=experien...]
n12{if self.db_type == 'hybrid'}
n13[db_backend = SQLiteBackend(db_pat...]
n14[jsonl_backend = JSONLBackend(data_di...]
n15[return HybridBackend(db_backend=db_ba...]
n16[raise ValueError(f'Unknown database type:...]
n17[]
n18[]
n19[]
n20[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n20
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n19
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n18
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建存儲後端&#39;]
n4{if self.db_type == &#39;sqlite&#39;}
n5[db_path = self.db_config.get(&#39;...]
n6[return SQLiteBackend(db_path=db_path)]
n7{if self.db_type == &#39;postgres&#39;}
n8[return PostgreSQLBackend(host=self.db...]
n9{if self.db_type == &#39;jsonl&#39;}
n10[experiences_dir = self.db_config.get(&#39;...]
n11[return JSONLBackend(data_dir=experien...]
n12{if self.db_type == &#39;hybrid&#39;}
n13[db_backend = SQLiteBackend(db_pat...]
n14[jsonl_backend = JSONLBackend(data_di...]
n15[return HybridBackend(db_backend=db_ba...]
n16[raise ValueError(f&#39;Unknown database type:...]
n17[]
n18[]
n19[]
n20[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n20
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n19
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n18
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
463. core aiva core storage storage manager Function get dir size
flowchart TB
n1([開始])
n2([結束])
n3['計算目錄大小']
n4{if not path.exists()}
n5[return 0]
n6[]
n7[return sum((f.stat().st_size for f in...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算目錄大小&#39;]
n4{if not path.exists()}
n5[return 0]
n6[]
n7[return sum((f.stat().st_size for f in...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
464. core aiva core storage storage manager Function get path
flowchart TB
n1([開始])
n2([結束])
n3['獲取數據路徑']
n4{if category not in self.dirs}
n5[raise ValueError(f'Unknown category: ...]
n6[]
n7{if subcategory}
n8[paths = self.dirs[category]]
n9{if isinstance(paths, dict) and...}
n10[result = paths[subcategory]]
n11{if isinstance(result, Path)}
n12[return result]
n13[]
n14[raise TypeError(f'Path for {category...]
n15[raise ValueError(f'Unknown subcategory: &...]
n16[]
n17[]
n18[paths = self.dirs[category]]
n19{if isinstance(paths, dict)}
n20[result = paths.get('root')]
n21{if isinstance(result, Path)}
n22[return result]
n23[]
n24[raise TypeError(f'Root path for {cat...]
n25[]
n26{if isinstance(paths, Path)}
n27[return paths]
n28[]
n29[raise TypeError(f'Path for {category...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n17
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n15
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n25
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取數據路徑&#39;]
n4{if category not in self.dirs}
n5[raise ValueError(f&#39;Unknown category: ...]
n6[]
n7{if subcategory}
n8[paths = self.dirs[category]]
n9{if isinstance(paths, dict) and...}
n10[result = paths[subcategory]]
n11{if isinstance(result, Path)}
n12[return result]
n13[]
n14[raise TypeError(f&#39;Path for {category...]
n15[raise ValueError(f&#39;Unknown subcategory: &...]
n16[]
n17[]
n18[paths = self.dirs[category]]
n19{if isinstance(paths, dict)}
n20[result = paths.get(&#39;root&#39;)]
n21{if isinstance(result, Path)}
n22[return result]
n23[]
n24[raise TypeError(f&#39;Root path for {cat...]
n25[]
n26{if isinstance(paths, Path)}
n27[return paths]
n28[]
n29[raise TypeError(f&#39;Path for {category...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n17
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n15
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n25
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n2
465. core aiva core storage storage manager Function initialize
flowchart TB
n1([開始])
n2([結束])
n3['創建所有必要的目錄']
n4{for (_category, paths) in self.dirs.items()}
n5{if isinstance(paths, dict)}
n6{for path in paths.values()}
n7{if isinstance(path, Path)}
n8[path.mkdir(parents=True, exist_ok=True)]
n9[logger.debug(f'Created directory: {p...]
n10[]
n11[]
n12{if isinstance(paths, Path)}
n13[paths.mkdir(parents=True, exist_ok=True)]
n14[logger.debug(f'Created directory: {p...]
n15[]
n16[]
n17[]
n18[logger.info('All data directories initial...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n17
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n4
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建所有必要的目錄&#39;]
n4{for (_category, paths) in self.dirs.items()}
n5{if isinstance(paths, dict)}
n6{for path in paths.values()}
n7{if isinstance(path, Path)}
n8[path.mkdir(parents=True, exist_ok=True)]
n9[logger.debug(f&#39;Created directory: {p...]
n10[]
n11[]
n12{if isinstance(paths, Path)}
n13[paths.mkdir(parents=True, exist_ok=True)]
n14[logger.debug(f&#39;Created directory: {p...]
n15[]
n16[]
n17[]
n18[logger.info(&#39;All data directories initial...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n17
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n4
n17 --> n18
n18 --> n2
466. core aiva core training scenario manager Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化場景管理器\n\n Args:\n scena...]
n4[self.scenarios_dir = scenarios_dir or Pat...]
n5[self.scenarios_dir.mkdir(parents=True, exist_ok=Tr...]
n6[self.storage = storage_backend]
n7[self.scenarios: dict[str, StandardScenario] = ...]
n8[self.difficulty_scores = {'easy&#...]
n9[logger.info(f'ScenarioManager initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化場景管理器\n\n Args:\n scena...]
n4[self.scenarios_dir = scenarios_dir or Pat...]
n5[self.scenarios_dir.mkdir(parents=True, exist_ok=Tr...]
n6[self.storage = storage_backend]
n7[self.scenarios: dict[str, StandardScenario] = ...]
n8[self.difficulty_scores = {&#39;easy&#...]
n9[logger.info(f&#39;ScenarioManager initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
467. core aiva core training scenario manager Function create juice shop sql login plan
flowchart TB
n1([開始])
n2([結束])
n3['創建 Juice Shop SQL 登入繞過計畫']
n4[plan_id = f'plan_{uuid4().hex ...]
n5[scan_id = f'scan_{uuid4().hex ...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建 Juice Shop SQL 登入繞過計畫&#39;]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[scan_id = f&#39;scan_{uuid4().hex	...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
468. core aiva core training scenario manager Function create juice shop xss dom plan
flowchart TB
n1([開始])
n2([結束])
n3['創建 Juice Shop DOM XSS 計畫']
n4[plan_id = f'plan_{uuid4().hex ...]
n5[scan_id = f'scan_{uuid4().hex ...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建 Juice Shop DOM XSS 計畫&#39;]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[scan_id = f&#39;scan_{uuid4().hex	...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
469. core aiva core training scenario manager Function create sql injection plan easy
flowchart TB
n1([開始])
n2([結束])
n3['創建簡單 SQL 注入攻擊計畫']
n4[plan_id = f'plan_{uuid4().hex ...]
n5[scan_id = f'scan_{uuid4().hex ...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建簡單 SQL 注入攻擊計畫&#39;]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[scan_id = f&#39;scan_{uuid4().hex	...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
470. core aiva core training scenario manager Function create sql injection plan medium
flowchart TB
n1([開始])
n2([結束])
n3['創建中等難度 SQL 注入攻擊計畫']
n4[plan_id = f'plan_{uuid4().hex ...]
n5[scan_id = f'scan_{uuid4().hex ...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建中等難度 SQL 注入攻擊計畫&#39;]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[scan_id = f&#39;scan_{uuid4().hex	...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
471. core aiva core training scenario manager Function create ssrf plan medium
flowchart TB
n1([開始])
n2([結束])
n3['創建中等難度 SSRF 攻擊計畫']
n4[plan_id = f'plan_{uuid4().hex ...]
n5[scan_id = f'scan_{uuid4().hex ...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建中等難度 SSRF 攻擊計畫&#39;]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[scan_id = f&#39;scan_{uuid4().hex	...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
472. core aiva core training scenario manager Function create xss plan easy
flowchart TB
n1([開始])
n2([結束])
n3['創建簡單 XSS 攻擊計畫']
n4[plan_id = f'plan_{uuid4().hex ...]
n5[scan_id = f'scan_{uuid4().hex ...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建簡單 XSS 攻擊計畫&#39;]
n4[plan_id = f&#39;plan_{uuid4().hex	...]
n5[scan_id = f&#39;scan_{uuid4().hex	...]
n6[steps = [AttackStep(step_id=...]
n7[plan = AttackPlan(plan_id=p...]
n8[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
473. core aiva core training scenario manager Function estimate duration
flowchart TB
n1([開始])
n2([結束])
n3['估算計畫執行時間\n\n Args:\n plan:...]
n4[base_time = len(plan.steps) * 5....]
n5[timeout_sum = sum((step.timeout_se...]
n6[return max(base_time, timeout_sum * 0...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;估算計畫執行時間\n\n Args:\n plan:...]
n4[base_time = len(plan.steps) * 5....]
n5[timeout_sum = sum((step.timeout_se...]
n6[return max(base_time, timeout_sum * 0...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
474. core aiva core training training orchestrator Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化訓練編排器\n\n Args:\n scena...]
n4[self.scenario_manager = scenario_manager]
n5[self.rag_engine = rag_engine]
n6[self.plan_executor = plan_executor]
n7[self.experience_manager = experience_manager]
n8[self.model_trainer = model_trainer]
n9[self.data_directory = data_directory or Pa...]
n10[self.data_directory.mkdir(parents=True, exist_ok=T...]
n11[self.training_sessions: list[dict[str, Any]...]
n12[self.current_session: dict[str, Any] | None ...]
n13[logger.info('TrainingOrchestrator initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化訓練編排器\n\n Args:\n scena...]
n4[self.scenario_manager = scenario_manager]
n5[self.rag_engine = rag_engine]
n6[self.plan_executor = plan_executor]
n7[self.experience_manager = experience_manager]
n8[self.model_trainer = model_trainer]
n9[self.data_directory = data_directory or Pa...]
n10[self.data_directory.mkdir(parents=True, exist_ok=T...]
n11[self.training_sessions: list[dict[str, Any]&#...]
n12[self.current_session: dict[str, Any] | None ...]
n13[logger.info(&#39;TrainingOrchestrator initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
475. core aiva core training training orchestrator Function save single session
flowchart TB
n1([開始])
n2([結束])
n3['保存單個會話\n\n Args:\n session...]
n4[import json]
n5[session_file = self.data_directory ...]
n6[with open(sess...]
n7[json.dump(session, f, indent=2)]
n8[logger.info(f'Session saved: {sessio...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存單個會話\n\n Args:\n session...]
n4[import json]
n5[session_file = self.data_directory ...]
n6[with open(sess...]
n7[json.dump(session, f, indent=2)]
n8[logger.info(f&#39;Session saved: {sessio...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
476. core aiva core training training orchestrator Function get training statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取訓練統計信息\n\n Returns:\n 統計...]
n4[total_episodes = sum((len(session[&...]
n5[successful_episodes = sum((sum((1 for ep ...]
n6[return {'total_sessions': le...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取訓練統計信息\n\n Returns:\n 統計...]
n4[total_episodes = sum((len(session[&&#...]
n5[successful_episodes = sum((sum((1 for ep ...]
n6[return {&#39;total_sessions&#39;: le...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
477. core aiva core training training orchestrator Function save session
flowchart TB
n1([開始])
n2([結束])
n3['保存訓練會話\n\n Args:\n session...]
n4{if session_id is None}
n5{for session in self.training_ses...}
n6[self._save_single_session(session)]
n7[]
n8[session = next((s for s in sel...]
n9{if session}
n10[self._save_single_session(session)]
n11[]
n12[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存訓練會話\n\n Args:\n session...]
n4{if session_id is None}
n5{for session in self.training_ses...}
n6[self._save_single_session(session)]
n7[]
n8[session = next((s for s in sel...]
n9{if session}
n10[self._save_single_session(session)]
n11[]
n12[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
478. core aiva core ui panel auto server Function find free port
flowchart TB
n1([開始])
n2([結束])
n3['尋找可用的端口號.\n\n Args:\n start_port: ...]
n4{for port in range(start_port,...}
n5[try]
n6[with socket.so...]
n7[s.bind(('127.0.0.1', port...]
n8[return port]
n9[]
n10[except OSError]
n11[continue]
n12[]
n13[msg = f'無法在 {start_port}-{...]
n14[raise RuntimeError(msg)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n12
n5 --> n6
n5 --> n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n4
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;尋找可用的端口號.\n\n Args:\n start_port: ...]
n4{for port in range(start_port,...}
n5[try]
n6[with socket.so...]
n7[s.bind((&#39;127.0.0.1&#39;, port...]
n8[return port]
n9[]
n10[except OSError]
n11[continue]
n12[]
n13[msg = f&#39;無法在 {start_port}-{...]
n14[raise RuntimeError(msg)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n12
n5 --> n6
n5 --> n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n4
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 --> n2
479. core aiva core ui panel auto server Function main
flowchart TB
n1([開始])
n2([結束])
n3['主程式進入點.']
n4[import argparse]
n5[parser = argparse.ArgumentPar...]
n6[parser.add_argument('--mode',...]
n7[parser.add_argument('--host',...]
n8[parser.add_argument('--ports'...]
n9[args = parser.parse_args()]
n10[start_auto_server(mode=args.mode, host=args.host, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;主程式進入點.&#39;]
n4[import argparse]
n5[parser = argparse.ArgumentPar...]
n6[parser.add_argument(&#39;--mode&#39;,...]
n7[parser.add_argument(&#39;--host&#39;,...]
n8[parser.add_argument(&#39;--ports&#39;...]
n9[args = parser.parse_args()]
n10[start_auto_server(mode=args.mode, host=args.host, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
480. core aiva core ui panel auto server Function start auto server
flowchart TB
n1([開始])
n2([結束])
n3['啟動自動端口選擇的 UI 伺服器.\n\n Args:\n mode...]
n4[logging.basicConfig(level=logging.INFO, format=&&...]
n5[try]
n6[import uvicorn]
n7[from .improved_ui import create_app]
n8[]
n9[except ImportError]
n10[logger.error(f'匯入錯誤: {e}&...]
n11[logger.error('請確保已安裝所需套件: pip install fas...]
n12[return]
n13[app = create_app(mode=mode...]
n14[port = None]
n15{if preferred_ports}
n16{for preferred_port in preferred_ports}
n17[try]
n18[with socket.so...]
n19[s.bind((host, preferred_port))]
n20[port = preferred_port]
n21[logger.info(f'使用偏好端口: {port}&am...]
n22[break]
n23[]
n24[except OSError]
n25[continue]
n26[]
n27[]
n28{if port is None}
n29[try]
n30[port = find_free_port()]
n31[logger.info(f'自動選擇端口: {port}&am...]
n32[]
n33[except RuntimeError]
n34[logger.error(f'端口選擇失敗: {e}&...]
n35[return]
n36[]
n37[logger.info(f"\n{'=&...]
n38[logger.info(' 🚀 啟動 AIVA UI 面板 (自動端口...]
n39[logger.info(f"{'=&#...]
n40[logger.info(f'🌐 位址: http://{host...]
n41[logger.info(f'📖 API 文檔: http://{host...]
n42[logger.info(f'🔧 模式: {mode}&...]
n43[logger.info(f"{'=&#...]
n44[try]
n45[uvicorn.run(app, host=host, port=port, log_level=&...]
n46[]
n47[except OSError]
n48{if 'Address already in use' in...}
n49[logger.error(f'端口 {port} 被佔用,嘗試...]
n50[try]
n51[new_port = find_free_port(port ...]
n52[logger.info(f'使用新端口: {new_port}...]
n53[uvicorn.run(app, host=host, port=new_port, log_lev...]
n54[]
n55[except RuntimeError]
n56[logger.error(f'重試失敗: {retry_error...]
n57[logger.error(f'伺服器啟動失敗: {e}&...]
n58[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n9
n6 --> n7
n7 --> n8
n8 --> n13
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n8
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n27
n16 -->|Yes| n17
n16 -->|No| n26
n17 --> n18
n17 --> n24
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n16
n24 --> n25
n25 --> n23
n26 --> n27
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n36
n29 --> n30
n29 --> n33
n30 --> n31
n31 --> n32
n32 --> n36
n33 --> n34
n34 --> n35
n35 --> n32
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n44 --> n47
n45 --> n46
n46 --> n2
n47 --> n48
n48 -->|Yes| n49
n48 -->|No| n57
n49 --> n50
n50 --> n51
n50 --> n55
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n58
n55 --> n56
n56 --> n54
n57 --> n58
n58 --> n46
flowchart TB
n1([開始])
n2([結束])
n3[&#39;啟動自動端口選擇的 UI 伺服器.\n\n Args:\n mode...]
n4[logging.basicConfig(level=logging.INFO, format=&&...]
n5[try]
n6[import uvicorn]
n7[from .improved_ui import create_app]
n8[]
n9[except ImportError]
n10[logger.error(f&#39;匯入錯誤: {e}&&#...]
n11[logger.error(&#39;請確保已安裝所需套件: pip install fas...]
n12[return]
n13[app = create_app(mode=mode...]
n14[port = None]
n15{if preferred_ports}
n16{for preferred_port in preferred_ports}
n17[try]
n18[with socket.so...]
n19[s.bind((host, preferred_port))]
n20[port = preferred_port]
n21[logger.info(f&#39;使用偏好端口: {port}&am...]
n22[break]
n23[]
n24[except OSError]
n25[continue]
n26[]
n27[]
n28{if port is None}
n29[try]
n30[port = find_free_port()]
n31[logger.info(f&#39;自動選擇端口: {port}&am...]
n32[]
n33[except RuntimeError]
n34[logger.error(f&#39;端口選擇失敗: {e}&...]
n35[return]
n36[]
n37[logger.info(f&quot;\n{&#39;=&...]
n38[logger.info(&#39; 🚀 啟動 AIVA UI 面板 (自動端口...]
n39[logger.info(f&quot;{&#39;=&#...]
n40[logger.info(f&#39;🌐 位址: http://{host...]
n41[logger.info(f&#39;📖 API 文檔: http://{host...]
n42[logger.info(f&#39;🔧 模式: {mode}&...]
n43[logger.info(f&quot;{&#39;=&#...]
n44[try]
n45[uvicorn.run(app, host=host, port=port, log_level=&...]
n46[]
n47[except OSError]
n48{if &#39;Address already in use&#39; in...}
n49[logger.error(f&#39;端口 {port} 被佔用,嘗試...]
n50[try]
n51[new_port = find_free_port(port ...]
n52[logger.info(f&#39;使用新端口: {new_port}...]
n53[uvicorn.run(app, host=host, port=new_port, log_lev...]
n54[]
n55[except RuntimeError]
n56[logger.error(f&#39;重試失敗: {retry_error...]
n57[logger.error(f&#39;伺服器啟動失敗: {e}&...]
n58[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n9
n6 --> n7
n7 --> n8
n8 --> n13
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n8
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n27
n16 -->|Yes| n17
n16 -->|No| n26
n17 --> n18
n17 --> n24
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n16
n24 --> n25
n25 --> n23
n26 --> n27
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n36
n29 --> n30
n29 --> n33
n30 --> n31
n31 --> n32
n32 --> n36
n33 --> n34
n34 --> n35
n35 --> n32
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n44 --> n47
n45 --> n46
n46 --> n2
n47 --> n48
n48 -->|Yes| n49
n48 -->|No| n57
n49 --> n50
n50 --> n51
n50 --> n55
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n58
n55 --> n56
n56 --> n54
n57 --> n58
n58 --> n46
481. core aiva core ui panel dashboard Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化控制面板.\n\n Args:\n mode:...]
n4[self.mode = mode]
n5[self.ai_agent: Any = None]
n6[self.scan_tasks: list[dict[str, Any]] = &...]
n7[self.detection_results: list[dict[str, Any]...]
n8[logger.info(f"\n{'=&...]
n9[logger.info(' AIVA 控制面板初始化'...]
n10[logger.info(f"{'=&#...]
n11[logger.info(f'運作模式: {self._get_mode_...]
n12{if mode in ('ai', ...}
n13[self._init_ai_agent()]
n14[]
n15[logger.info(f"{'=&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化控制面板.\n\n Args:\n mode:...]
n4[self.mode = mode]
n5[self.ai_agent: Any = None]
n6[self.scan_tasks: list[dict[str, Any]] = &...]
n7[self.detection_results: list[dict[str, Any]&#...]
n8[logger.info(f&quot;\n{&#39;=&...]
n9[logger.info(&#39; AIVA 控制面板初始化&#39;...]
n10[logger.info(f&quot;{&#39;=&#...]
n11[logger.info(f&#39;運作模式: {self._get_mode_...]
n12{if mode in (&#39;ai&#39;, &#3...}
n13[self._init_ai_agent()]
n14[]
n15[logger.info(f&quot;{&#39;=&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n2
482. core aiva core ui panel dashboard Function get mode display
flowchart TB
n1([開始])
n2([結束])
n3['獲取模式的顯示名稱.']
n4[mode_map = {'ui': &#...]
n5[return mode_map.get(self.mode, '未知模式&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取模式的顯示名稱.&#39;]
n4[mode_map = {&#39;ui&#39;: &#...]
n5[return mode_map.get(self.mode, &#39;未知模式&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
483. core aiva core ui panel dashboard Function init ai agent
flowchart TB
n1([開始])
n2([結束])
n3['初始化 AI 代理.']
n4[try]
n5[from ..ai_engine import BioNeuronRAGAgent]
n6[logger.info('\n[AI] 正在初始化 BioNeur...]
n7[self.ai_agent = BioNeuronRAGAgent(co...]
n8[logger.info('[AI] AI 代理初始化成功&...]
n9[]
n10[except Exception]
n11[logger.error(f'[AI] AI 代理初始化失敗: &...]
n12{if self.mode == 'ai'}
n13[raise]
n14[]
n15[logger.warning('[AI] 將以純 UI 模式運作&...]
n16[self.mode = 'ui']
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n10
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n9
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 AI 代理.&#39;]
n4[try]
n5[from ..ai_engine import BioNeuronRAGAgent]
n6[logger.info(&#39;\n[AI] 正在初始化 BioNeur...]
n7[self.ai_agent = BioNeuronRAGAgent(co...]
n8[logger.info(&#39;[AI] AI 代理初始化成功&...]
n9[]
n10[except Exception]
n11[logger.error(f&#39;[AI] AI 代理初始化失敗: &...]
n12{if self.mode == &#39;ai&#39;}
n13[raise]
n14[]
n15[logger.warning(&#39;[AI] 將以純 UI 模式運作&...]
n16[self.mode = &#39;ui&#39;]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n10
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n9
484. core aiva core ui panel dashboard Function analyze code
flowchart TB
n1([開始])
n2([結束])
n3['分析程式碼.\n\n Args:\n file_pa...]
n4{if use_ai is None}
n5[use_ai = self.mode in ('ai', ...]
n6[]
n7{if use_ai and self.ai_agent}
n8[logger.info(f'\n[AI] 使用 AI 代理分析程式...]
n9[result = self.ai_agent.invoke...]
n10[return result]
n11[logger.info(f'\n[UI] 使用 UI 模式分析程式...]
n12[from pathlib import Path]
n13[try]
n14[content = Path(f'c:/D/E/AIVA/A...]
n15[lines = content.splitlines()]
n16[return {'status': &#...]
n17[]
n18[except Exception]
n19[return {'status': &#...]
n20[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n20
n11 --> n12
n12 --> n13
n13 --> n14
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n20
n18 --> n19
n19 --> n17
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析程式碼.\n\n Args:\n file_pa...]
n4{if use_ai is None}
n5[use_ai = self.mode in (&#39;ai&#39;, ...]
n6[]
n7{if use_ai and self.ai_agent}
n8[logger.info(f&#39;\n[AI] 使用 AI 代理分析程式...]
n9[result = self.ai_agent.invoke...]
n10[return result]
n11[logger.info(f&#39;\n[UI] 使用 UI 模式分析程式...]
n12[from pathlib import Path]
n13[try]
n14[content = Path(f&#39;c:/D/E/AIVA/A...]
n15[lines = content.splitlines()]
n16[return {&#39;status&#39;: &#...]
n17[]
n18[except Exception]
n19[return {&#39;status&#39;: &#...]
n20[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n20
n11 --> n12
n12 --> n13
n13 --> n14
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n20
n18 --> n19
n19 --> n17
n20 --> n2
485. core aiva core ui panel dashboard Function detect vulnerability
flowchart TB
n1([開始])
n2([結束])
n3['執行漏洞檢測.\n\n Args:\n vuln_t...]
n4{if use_ai is None}
n5[use_ai = self.mode in ('ai', ...]
n6[]
n7{if use_ai and self.ai_agent}
n8[logger.info(f'\n[AI] 使用 AI 代理執行 &...]
n9[result = self.ai_agent.invoke...]
n10[detection = {'vuln_type': vu...]
n11[logger.info(f'\n[UI] 使用 UI 模式執行 &...]
n12[detection = {'vuln_type': vu...]
n13[]
n14[self.detection_results.append(detection)]
n15[return detection]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行漏洞檢測.\n\n Args:\n vuln_t...]
n4{if use_ai is None}
n5[use_ai = self.mode in (&#39;ai&#39;, ...]
n6[]
n7{if use_ai and self.ai_agent}
n8[logger.info(f&#39;\n[AI] 使用 AI 代理執行 &...]
n9[result = self.ai_agent.invoke...]
n10[detection = {&#39;vuln_type&#39;: vu...]
n11[logger.info(f&#39;\n[UI] 使用 UI 模式執行 &...]
n12[detection = {&#39;vuln_type&#39;: vu...]
n13[]
n14[self.detection_results.append(detection)]
n15[return detection]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
486. core aiva core ui panel dashboard Function get ai history
flowchart TB
n1([開始])
n2([結束])
n3['獲取 AI 代理的執行歷史.']
n4{if self.ai_agent}
n5[return self.ai_agent.get_history()]
n6[]
n7[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取 AI 代理的執行歷史.&#39;]
n4{if self.ai_agent}
n5[return self.ai_agent.get_history()]
n6[]
n7[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
487. core aiva core ui panel dashboard Function get detections
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有檢測結果.']
n4[return self.detection_results]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有檢測結果.&#39;]
n4[return self.detection_results]
n1 --> n3
n3 --> n4
n4 --> n2
488. core aiva core ui panel dashboard Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計資訊.']
n4[stats = {'mode': self.mode, ...]
n5{if self.ai_agent}
n6[ai_stats = self.ai_agent.get_kn...]
n7[stats.update({'ai_chunks'...]
n8[]
n9[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計資訊.&#39;]
n4[stats = {&#39;mode&#39;: self.mode, ...]
n5{if self.ai_agent}
n6[ai_stats = self.ai_agent.get_kn...]
n7[stats.update({&#39;ai_chunks&#39...]
n8[]
n9[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
489. core aiva core ui panel dashboard Function get tasks
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有掃描任務.']
n4[return self.scan_tasks]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有掃描任務.&#39;]
n4[return self.scan_tasks]
n1 --> n3
n3 --> n4
n4 --> n2
490. core aiva core ui panel dashboard Function read code
flowchart TB
n1([開始])
n2([結束])
n3['讀取程式碼檔案.\n\n Args:\n file_...]
n4{if use_ai is None}
n5[use_ai = self.mode in ('ai', ...]
n6[]
n7{if use_ai and self.ai_agent}
n8[logger.info(f'\n[AI] 使用 AI 代理讀取檔案...]
n9[result = self.ai_agent.invoke...]
n10[return result]
n11[logger.info(f'\n[UI] 使用 UI 模式讀取檔案...]
n12[from pathlib import Path]
n13[try]
n14[content = Path(f'c:/D/E/AIVA/A...]
n15[return {'status': &#...]
n16[]
n17[except Exception]
n18[return {'status': &#...]
n19[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n19
n11 --> n12
n12 --> n13
n13 --> n14
n13 --> n17
n14 --> n15
n15 --> n16
n16 --> n19
n17 --> n18
n18 --> n16
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;讀取程式碼檔案.\n\n Args:\n file_...]
n4{if use_ai is None}
n5[use_ai = self.mode in (&#39;ai&#39;, ...]
n6[]
n7{if use_ai and self.ai_agent}
n8[logger.info(f&#39;\n[AI] 使用 AI 代理讀取檔案...]
n9[result = self.ai_agent.invoke...]
n10[return result]
n11[logger.info(f&#39;\n[UI] 使用 UI 模式讀取檔案...]
n12[from pathlib import Path]
n13[try]
n14[content = Path(f&#39;c:/D/E/AIVA/A...]
n15[return {&#39;status&#39;: &#...]
n16[]
n17[except Exception]
n18[return {&#39;status&#39;: &#...]
n19[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n19
n11 --> n12
n12 --> n13
n13 --> n14
n13 --> n17
n14 --> n15
n15 --> n16
n16 --> n19
n17 --> n18
n18 --> n16
n19 --> n2
491. core aiva core ui panel improved ui Function build index html
flowchart TB
n1([開始])
n2([結束])
n3['Construct the HTML for the index page.\n\n ...]
n4[stats: dict[str, Any] = dashboard.get_stats(&...]
n5[tasks = dashboard.get_tasks(...]
n6[detections = dashboard.get_detect...]
n7[ai_history = dashboard.get_ai_his...]
n8[task_rows = '']
n9{for task in tasks}
n10[task_id = task.get('task_id',...]
n11[target = task.get('target', &...]
n12[scan_type = task.get('scan_type&#...]
n13[status = task.get('status', &...]
n14[created_by = task.get('created_by...]
n15[ai_result = task.get('ai_result&#...]
n16[ai_result_text = 'AI' if ai_resul...]
n17[task_rows += f'<tr><td&a...]
n18[]
n19{if not task_rows}
n20[task_rows = "<tr><td colspa...]
n21[]
n22[detection_rows = '']
n23{for det in detections}
n24[vuln_type = det.get('vuln_type...]
n25[target = det.get('target', &a...]
n26[status = det.get('status', &a...]
n27[method = det.get('method', &a...]
n28[result = det.get('result', de...]
n29{if isinstance(result, list | d...}
n30[result_preview = '[複雜結果]']
n31[result_str = str(result)]
n32[result_preview = result_str[:50] + (&#...]
n33[]
n34[detection_rows += f'<tr><...]
n35[]
n36{if not detection_rows}
n37[detection_rows = "<tr><td c...]
n38[]
n39[history_rows = '']
n40{for record in ai_history}
n41[status = record.get('status',...]
n42[tool_used = record.get('tool_use...]
n43[confidence = record.get('confiden...]
n44[result = record.get('result',...]
n45{if isinstance(confidence, float)}
n46[conf_display = f'{confidence:.2%}&a...]
n47[conf_display = str(confidence)]
n48[]
n49[result_str = str(result)]
n50[result_preview = result_str[:50] + (&#...]
n51[history_rows += f'<tr><t...]
n52[]
n53{if not history_rows}
n54[history_rows = "<tr><td col...]
n55[]
n56[ai_card_html: str = '']
n57{if stats.get('ai_enabled')}
n58[ai_card_html = '\n <...]
n59[]
n60[html = f"""\n <!DOCT...]
n61[return html]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n18
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n9
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n35
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n33
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n23
n35 --> n36
n36 -->|Yes| n37
n36 -->|No| n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 -->|Yes| n41
n40 -->|No| n52
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 -->|Yes| n46
n45 -->|No| n47
n46 --> n48
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n40
n52 --> n53
n53 -->|Yes| n54
n53 -->|No| n55
n54 --> n55
n55 --> n56
n56 --> n57
n57 -->|Yes| n58
n57 -->|No| n59
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Construct the HTML for the index page.\n\n ...]
n4[stats: dict[str, Any] = dashboard.get_stats(&...]
n5[tasks = dashboard.get_tasks(...]
n6[detections = dashboard.get_detect...]
n7[ai_history = dashboard.get_ai_his...]
n8[task_rows = &#39;&#39;]
n9{for task in tasks}
n10[task_id = task.get(&#39;task_id&#39;,...]
n11[target = task.get(&#39;target&#39;, &...]
n12[scan_type = task.get(&#39;scan_type&#...]
n13[status = task.get(&#39;status&#39;, &...]
n14[created_by = task.get(&#39;created_by...]
n15[ai_result = task.get(&#39;ai_result&#...]
n16[ai_result_text = &#39;AI&#39; if ai_resul...]
n17[task_rows += f&#39;&lt;tr&gt;&lt;td&a...]
n18[]
n19{if not task_rows}
n20[task_rows = &quot;&lt;tr&gt;&lt;td colspa...]
n21[]
n22[detection_rows = &#39;&#39;]
n23{for det in detections}
n24[vuln_type = det.get(&#39;vuln_type&#3...]
n25[target = det.get(&#39;target&#39;, &a...]
n26[status = det.get(&#39;status&#39;, &a...]
n27[method = det.get(&#39;method&#39;, &a...]
n28[result = det.get(&#39;result&#39;, de...]
n29{if isinstance(result, list | d...}
n30[result_preview = &#39;[複雜結果]&#39;]
n31[result_str = str(result)]
n32[result_preview = result_str[:50] + (&#...]
n33[]
n34[detection_rows += f&#39;&lt;tr&gt;&lt...]
n35[]
n36{if not detection_rows}
n37[detection_rows = &quot;&lt;tr&gt;&lt;td c...]
n38[]
n39[history_rows = &#39;&#39;]
n40{for record in ai_history}
n41[status = record.get(&#39;status&#39;,...]
n42[tool_used = record.get(&#39;tool_use...]
n43[confidence = record.get(&#39;confiden...]
n44[result = record.get(&#39;result&#39;,...]
n45{if isinstance(confidence, float)}
n46[conf_display = f&#39;{confidence:.2%}&a...]
n47[conf_display = str(confidence)]
n48[]
n49[result_str = str(result)]
n50[result_preview = result_str[:50] + (&#...]
n51[history_rows += f&#39;&lt;tr&gt;&lt;t...]
n52[]
n53{if not history_rows}
n54[history_rows = &quot;&lt;tr&gt;&lt;td col...]
n55[]
n56[ai_card_html: str = &#39;&#39;]
n57{if stats.get(&#39;ai_enabled&#39;)}
n58[ai_card_html = &#39;\n &lt;...]
n59[]
n60[html = f&quot;&quot;&quot;\n &lt;!DOCT...]
n61[return html]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n18
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n9
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n35
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n33
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n23
n35 --> n36
n36 -->|Yes| n37
n36 -->|No| n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 -->|Yes| n41
n40 -->|No| n52
n41 --> n42
n42 --> n43
n43 --> n44
n44 --> n45
n45 -->|Yes| n46
n45 -->|No| n47
n46 --> n48
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n40
n52 --> n53
n53 -->|Yes| n54
n53 -->|No| n55
n54 --> n55
n55 --> n56
n56 --> n57
n57 -->|Yes| n58
n57 -->|No| n59
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n2
492. core aiva core ui panel improved ui Function create app
flowchart TB
n1([開始])
n2([結束])
n3['Create a FastAPI app with the improved UI.\n...]
n4[dashboard = Dashboard(mode=mode)]
n5[app = FastAPI(title='AIVA ...]
n6[def index(...)]
n7[def api_stats(...)]
n8[def api_tasks(...)]
n9[def api_detections(...)]
n10[def api_create_scan(...)]
n11[def api_detect_vuln(...)]
n12[def api_ai_history(...)]
n13[return app]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Create a FastAPI app with the improved UI.\n...]
n4[dashboard = Dashboard(mode=mode)]
n5[app = FastAPI(title=&#39;AIVA ...]
n6[def index(...)]
n7[def api_stats(...)]
n8[def api_tasks(...)]
n9[def api_detections(...)]
n10[def api_create_scan(...)]
n11[def api_detect_vuln(...)]
n12[def api_ai_history(...)]
n13[return app]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
493. core aiva core ui panel server Function find free port
flowchart TB
n1([開始])
n2([結束])
n3['尋找可用的端口號.\n\n Args:\n start_port: ...]
n4{for port in range(start_port,...}
n5[try]
n6[with socket.so...]
n7[s.bind(('127.0.0.1', port...]
n8[return port]
n9[]
n10[except OSError]
n11[continue]
n12[]
n13[msg = f'無法在 {start_port}-{...]
n14[raise RuntimeError(msg)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n12
n5 --> n6
n5 --> n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n4
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;尋找可用的端口號.\n\n Args:\n start_port: ...]
n4{for port in range(start_port,...}
n5[try]
n6[with socket.so...]
n7[s.bind((&#39;127.0.0.1&#39;, port...]
n8[return port]
n9[]
n10[except OSError]
n11[continue]
n12[]
n13[msg = f&#39;無法在 {start_port}-{...]
n14[raise RuntimeError(msg)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n12
n5 --> n6
n5 --> n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n4
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n14
n14 --> n2
494. core aiva core ui panel server Function start ui server
flowchart TB
n1([開始])
n2([結束])
n3['啟動 UI 面板伺服器.\n\n Args:\n mode: 運作模...]
n4[try]
n5[from fastapi import FastAPI]
n6[from fastapi.responses import HTMLResponse]
n7[]
n8[except ImportError]
n9[logger.error('錯誤: 需要安裝 FastAPI...]
n10[logger.error('請執行: pip install fastapi uv...]
n11[return]
n12[from .dashboard import Dashboard]
n13[app = FastAPI(title='AIVA ...]
n14[dashboard = Dashboard(mode=mode)]
n15[def index(...)]
n16[def get_stats(...)]
n17[def get_tasks(...)]
n18[def get_detections(...)]
n19[def create_scan(...)]
n20[def detect_vuln(...)]
n21[def read_code(...)]
n22[def analyze_code(...)]
n23[def get_ai_history(...)]
n24{if port is None}
n25[try]
n26[port = find_free_port()]
n27[logger.info(f'自動選擇可用端口: {port}&...]
n28[]
n29[except RuntimeError]
n30[logger.error(f'端口選擇失敗: {e}&...]
n31[return]
n32[]
n33[logger.info(f"\n{'=&...]
n34[logger.info(' 啟動 AIVA UI 面板伺服器&#...]
n35[logger.info(f"{'=&#...]
n36[logger.info(f'位址: http://{host}...]
n37[logger.info(f'API 文檔: http://{host...]
n38[logger.info(f"{'=&#...]
n39[try]
n40[import uvicorn]
n41[uvicorn.run(app, host=host, port=port, log_level=&...]
n42[]
n43[except ImportError]
n44[logger.error('錯誤: 需要安裝 uvicorn...]
n45[logger.error('請執行: pip install uvicorn&am...]
n46[except OSError]
n47{if 'Address already in use' in...}
n48[logger.error(f'端口 {port} 已被佔用,嘗...]
n49[try]
n50[new_port = find_free_port(port ...]
n51[logger.info(f'使用新端口: {new_port}...]
n52[uvicorn.run(app, host=host, port=new_port, log_lev...]
n53[]
n54[except (RuntimeErro...]
n55[logger.error(f'重試失敗: {retry_error...]
n56[logger.error(f'伺服器啟動失敗: {e}&...]
n57[]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n32
n25 --> n26
n25 --> n29
n26 --> n27
n27 --> n28
n28 --> n32
n29 --> n30
n30 --> n31
n31 --> n28
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n39 --> n43
n39 --> n46
n40 --> n41
n41 --> n42
n42 --> n2
n43 --> n44
n44 --> n45
n45 --> n42
n46 --> n47
n47 -->|Yes| n48
n47 -->|No| n56
n48 --> n49
n49 --> n50
n49 --> n54
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n57
n54 --> n55
n55 --> n53
n56 --> n57
n57 --> n42
flowchart TB
n1([開始])
n2([結束])
n3[&#39;啟動 UI 面板伺服器.\n\n Args:\n mode: 運作模...]
n4[try]
n5[from fastapi import FastAPI]
n6[from fastapi.responses import HTMLResponse]
n7[]
n8[except ImportError]
n9[logger.error(&#39;錯誤: 需要安裝 FastAPI&#3...]
n10[logger.error(&#39;請執行: pip install fastapi uv...]
n11[return]
n12[from .dashboard import Dashboard]
n13[app = FastAPI(title=&#39;AIVA ...]
n14[dashboard = Dashboard(mode=mode)]
n15[def index(...)]
n16[def get_stats(...)]
n17[def get_tasks(...)]
n18[def get_detections(...)]
n19[def create_scan(...)]
n20[def detect_vuln(...)]
n21[def read_code(...)]
n22[def analyze_code(...)]
n23[def get_ai_history(...)]
n24{if port is None}
n25[try]
n26[port = find_free_port()]
n27[logger.info(f&#39;自動選擇可用端口: {port}&...]
n28[]
n29[except RuntimeError]
n30[logger.error(f&#39;端口選擇失敗: {e}&...]
n31[return]
n32[]
n33[logger.info(f&quot;\n{&#39;=&...]
n34[logger.info(&#39; 啟動 AIVA UI 面板伺服器&#...]
n35[logger.info(f&quot;{&#39;=&#...]
n36[logger.info(f&#39;位址: http://{host}...]
n37[logger.info(f&#39;API 文檔: http://{host&#...]
n38[logger.info(f&quot;{&#39;=&#...]
n39[try]
n40[import uvicorn]
n41[uvicorn.run(app, host=host, port=port, log_level=&...]
n42[]
n43[except ImportError]
n44[logger.error(&#39;錯誤: 需要安裝 uvicorn&#3...]
n45[logger.error(&#39;請執行: pip install uvicorn&am...]
n46[except OSError]
n47{if &#39;Address already in use&#39; in...}
n48[logger.error(f&#39;端口 {port} 已被佔用,嘗...]
n49[try]
n50[new_port = find_free_port(port ...]
n51[logger.info(f&#39;使用新端口: {new_port}...]
n52[uvicorn.run(app, host=host, port=new_port, log_lev...]
n53[]
n54[except (RuntimeErro...]
n55[logger.error(f&#39;重試失敗: {retry_error...]
n56[logger.error(f&#39;伺服器啟動失敗: {e}&...]
n57[]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n32
n25 --> n26
n25 --> n29
n26 --> n27
n27 --> n28
n28 --> n32
n29 --> n30
n30 --> n31
n31 --> n28
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n39 --> n43
n39 --> n46
n40 --> n41
n41 --> n42
n42 --> n2
n43 --> n44
n44 --> n45
n45 --> n42
n46 --> n47
n47 -->|Yes| n48
n47 -->|No| n56
n48 --> n49
n49 --> n50
n49 --> n54
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n57
n54 --> n55
n55 --> n53
n56 --> n57
n57 --> n42
495. core models Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
496. function init Module
flowchart TB
n1([開始])
n2([結束])
n3['\nAIVA Function - 功能模組\n\n這是 AIVA 的功能模組包,包含各...]
n4[__version__ = '1.0.0']
n5[from ..aiva_common.enums import Confidence, Severi...]
n6[from ..aiva_common.schemas import CVSSv3Metrics]
n7[from .models import APISchemaPayload, APISecurityT...]
n8[__all__ = ['Confidence', &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nAIVA Function - 功能模組\n\n這是 AIVA 的功能模組包,包含各...]
n4[__version__ = &#39;1.0.0&#39;]
n5[from ..aiva_common.enums import Confidence, Severi...]
n6[from ..aiva_common.schemas import CVSSv3Metrics]
n7[from .models import APISchemaPayload, APISecurityT...]
n8[__all__ = [&#39;Confidence&#39;, &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
497. function common init Module
flowchart TB
n1([開始])
n2([結束])
n3['\nCommon services - 統一的檢測基礎設施\n為所有功能模組提供統一的配...]
n4[from .detection_config import BaseDetectionConfig,...]
n5[from .unified_smart_detection_manager import Detec...]
n6[__all__ = ['BaseDetectionConfi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nCommon services - 統一的檢測基礎設施\n為所有功能模組提供統一的配...]
n4[from .detection_config import BaseDetectionConfig,...]
n5[from .unified_smart_detection_manager import Detec...]
n6[__all__ = [&#39;BaseDetectionConfi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
498. function common advanced detection config Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.config = UnifiedDetectionConf...]
n4[self.config_history: list[dict[str, Any]]...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.config = UnifiedDetectionConf...]
n4[self.config_history: list[dict[str, Any]]...]
n1 --> n3
n3 --> n4
n4 --> n2
499. function common advanced detection config Function get compliance audit preset
flowchart TB
n1([開始])
n2([結束])
n3['合規審計預設配置']
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.COMPLI...]
n6[config.report_level = ReportLevel.DETAILED]
n7[config.security_config.gdpr_compliance = True]
n8[config.security_config.audit_logging_enabled = True]
n9[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;合規審計預設配置&#39;]
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.COMPLI...]
n6[config.report_level = ReportLevel.DETAILED]
n7[config.security_config.gdpr_compliance = True]
n8[config.security_config.audit_logging_enabled = True]
n9[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
500. function common advanced detection config Function get continuous monitoring preset
flowchart TB
n1([開始])
n2([結束])
n3['持續監控預設配置']
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.STEALT...]
n6[config.report_level = ReportLevel.SUMMARY]
n7[config.schedule_enabled = True]
n8[config.schedule_cron = '0 2 * * *']
n9[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;持續監控預設配置&#39;]
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.STEALT...]
n6[config.report_level = ReportLevel.SUMMARY]
n7[config.schedule_enabled = True]
n8[config.schedule_cron = &#39;0 2 * * *&#39;]
n9[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
501. function common advanced detection config Function get penetration test preset
flowchart TB
n1([開始])
n2([結束])
n3['滲透測試預設配置']
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.COMPRE...]
n6[config.report_level = ReportLevel.VERBOSE]
n7[config.sqli_config.waf_bypass_enabled = True]
n8[config.ssrf_config.blind_ssrf_detection = True]
n9[config.xss_config.csp_bypass_enabled = True]
n10[config.idor_config.intelligent_id_analysis = True]
n11[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;滲透測試預設配置&#39;]
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.COMPRE...]
n6[config.report_level = ReportLevel.VERBOSE]
n7[config.sqli_config.waf_bypass_enabled = True]
n8[config.ssrf_config.blind_ssrf_detection = True]
n9[config.xss_config.csp_bypass_enabled = True]
n10[config.idor_config.intelligent_id_analysis = True]
n11[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
502. function common advanced detection config Function get red team preset
flowchart TB
n1([開始])
n2([結束])
n3['紅隊模擬預設配置']
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.COMPRE...]
n6[config.report_level = ReportLevel.VERBOSE]
n7[config.sqli_config.waf_bypass_enabled = True]
n8[config.ssrf_config.bypass_techniques_enabled = dict.fromk...]
n9[config.xss_config.waf_bypass_payloads = True]
n10[config.idor_config.advanced_enumeration = dict.fromkeys...]
n11[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;紅隊模擬預設配置&#39;]
n4[config = UnifiedDetectionConf...]
n5[config.detection_mode = DetectionMode.COMPRE...]
n6[config.report_level = ReportLevel.VERBOSE]
n7[config.sqli_config.waf_bypass_enabled = True]
n8[config.ssrf_config.bypass_techniques_enabled = dict.fromk...]
n9[config.xss_config.waf_bypass_payloads = True]
n10[config.idor_config.advanced_enumeration = dict.fromkeys&#...]
n11[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
503. function common advanced detection config Function save config history
flowchart TB
n1([開始])
n2([結束])
n3['保存配置歷史']
n4[self.config_history.append({'timesta...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存配置歷史&#39;]
n4[self.config_history.append({&#39;timesta...]
n1 --> n3
n3 --> n4
n4 --> n2
504. function common advanced detection config Function apply preset
flowchart TB
n1([開始])
n2([結束])
n3['應用預設配置']
n4[presets = {'penetration_test'...]
n5{if preset_name in presets}
n6[self.config = presets[preset_name]]
n7[self._save_config_history()]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;應用預設配置&#39;]
n4[presets = {&#39;penetration_test&#39...]
n5{if preset_name in presets}
n6[self.config = presets[preset_name]]
n7[self._save_config_history()]
n8[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n2
505. function common advanced detection config Function from dict
flowchart TB
n1([開始])
n2([結束])
n3['從字典創建配置']
n4[pass]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從字典創建配置&#39;]
n4[pass]
n1 --> n3
n3 --> n4
n4 --> n2
506. function common advanced detection config Function get effective config
flowchart TB
n1([開始])
n2([結束])
n3['獲取特定模組的有效配置']
n4[module_configs = {'sqli': se...]
n5[return module_configs.get(module_name...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取特定模組的有效配置&#39;]
n4[module_configs = {&#39;sqli&#39;: se...]
n5[return module_configs.get(module_name...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
507. function common advanced detection config Function load from file
flowchart TB
n1([開始])
n2([結束])
n3['從文件加載配置']
n4[import json]
n5[with open(file...]
n6[config_dict = json.load(f)]
n7[return cls.from_dict(config_dict)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從文件加載配置&#39;]
n4[import json]
n5[with open(file...]
n6[config_dict = json.load(f)]
n7[return cls.from_dict(config_dict)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
508. function common advanced detection config Function save to file
flowchart TB
n1([開始])
n2([結束])
n3['保存配置到文件']
n4[import json]
n5[with open(file...]
n6[json.dump(self.to_dict(), f, indent=2, ensure...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存配置到文件&#39;]
n4[import json]
n5[with open(file...]
n6[json.dump(self.to_dict(), f, indent=2, ensure...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
509. function common advanced detection config Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典格式']
n4[return {'sqli': self.sqli_co...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典格式&#39;]
n4[return {&#39;sqli&#39;: self.sqli_co...]
n1 --> n3
n3 --> n4
n4 --> n2
510. function common advanced detection config Function validate config
flowchart TB
n1([開始])
n2([結束])
n3['驗證配置有效性']
n4[errors = []]
n5{if self.config.sqli_config.tim...}
n6[errors.append('SQLi: timeout_base cannot ...]
n7[]
n8{if self.config.performance_con...}
n9[errors.append('Performance: max_concurren...]
n10[]
n11[return errors]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證配置有效性&#39;]
n4[errors = []]
n5{if self.config.sqli_config.tim...}
n6[errors.append(&#39;SQLi: timeout_base cannot ...]
n7[]
n8{if self.config.performance_con...}
n9[errors.append(&#39;Performance: max_concurren...]
n10[]
n11[return errors]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
511. function common advanced detection config Module
flowchart TB
n1([開始])
n2([結束])
n3['\n進階檢測配置系統 - 功能增強和優化\n基於現有 detection_config....]
n4[from __future__ import annotations]
n5[import os]
n6[from dataclasses import dataclass, field]
n7[from enum import Enum]
n8[from typing import Any, Optional, Union]
n9[from datetime import datetime, timedelta]
n10[from .detection_config import BaseDetectionConfig,...]
n11[class DetectionMode(...)]
n12[class ReportLevel(...)]
n13[class SQLiConfig(...)]
n14[class AdvancedSSRFConfig(...)]
n15[class AdvancedXSSConfig(...)]
n16[class AdvancedIDORConfig(...)]
n17[class PerformanceConfig(...)]
n18[class SecurityConfig(...)]
n19[class EnvironmentConfig(...)]
n20[class UnifiedDetectionConfig(...)]
n21[class ConfigurationManager(...)]
n22[DEFAULT_CONFIG_MANAGER = ConfigurationManager...]
n23[DEFAULT_UNIFIED_CONFIG = UnifiedDetectionConf...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n進階檢測配置系統 - 功能增強和優化\n基於現有 detection_config....]
n4[from __future__ import annotations]
n5[import os]
n6[from dataclasses import dataclass, field]
n7[from enum import Enum]
n8[from typing import Any, Optional, Union]
n9[from datetime import datetime, timedelta]
n10[from .detection_config import BaseDetectionConfig,...]
n11[class DetectionMode(...)]
n12[class ReportLevel(...)]
n13[class SQLiConfig(...)]
n14[class AdvancedSSRFConfig(...)]
n15[class AdvancedXSSConfig(...)]
n16[class AdvancedIDORConfig(...)]
n17[class PerformanceConfig(...)]
n18[class SecurityConfig(...)]
n19[class EnvironmentConfig(...)]
n20[class UnifiedDetectionConfig(...)]
n21[class ConfigurationManager(...)]
n22[DEFAULT_CONFIG_MANAGER = ConfigurationManager...]
n23[DEFAULT_UNIFIED_CONFIG = UnifiedDetectionConf...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
512. function common detection config Function apply to config
flowchart TB
n1([開始])
n2([結束])
n3['將策略應用到配置']
n4{if self.strategy_type == self....}
n5[config.max_vulnerabilities = 2]
n6[config.requests_per_second = 0.2]
n7[config.timeout_base = 3.0]
n8[config.timeout_max = 8.0]
n9{if self.strategy_type == self....}
n10[config.max_vulnerabilities = 10]
n11[config.requests_per_second = 1.0]
n12[config.timeout_base = 10.0]
n13[config.timeout_max = 30.0]
n14[]
n15[]
n16[return config]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n9
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n14
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將策略應用到配置&#39;]
n4{if self.strategy_type == self....}
n5[config.max_vulnerabilities = 2]
n6[config.requests_per_second = 0.2]
n7[config.timeout_base = 3.0]
n8[config.timeout_max = 8.0]
n9{if self.strategy_type == self....}
n10[config.max_vulnerabilities = 10]
n11[config.requests_per_second = 1.0]
n12[config.timeout_base = 10.0]
n13[config.timeout_max = 30.0]
n14[]
n15[]
n16[return config]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n9
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n14
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
513. function common detection config Module
flowchart TB
n1([開始])
n2([結束])
n3['\n統一檢測配置系統 - 基於 SQLi 模組成功經驗\n為所有功能模組提供統一的配置管...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[class BaseDetectionConfig(...)]
n7[class SSRFConfig(...)]
n8[class XSSConfig(...)]
n9[class IDORConfig(...)]
n10[class DetectionStrategy(...)]
n11[DEFAULT_SSRF_CONFIG = SSRFConfig()]
n12[DEFAULT_XSS_CONFIG = XSSConfig()]
n13[DEFAULT_IDOR_CONFIG = IDORConfig()]
n14[CONSERVATIVE_STRATEGY = DetectionStrategy(De...]
n15[BALANCED_STRATEGY = DetectionStrategy(De...]
n16[AGGRESSIVE_STRATEGY = DetectionStrategy(De...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n統一檢測配置系統 - 基於 SQLi 模組成功經驗\n為所有功能模組提供統一的配置管...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[class BaseDetectionConfig(...)]
n7[class SSRFConfig(...)]
n8[class XSSConfig(...)]
n9[class IDORConfig(...)]
n10[class DetectionStrategy(...)]
n11[DEFAULT_SSRF_CONFIG = SSRFConfig()]
n12[DEFAULT_XSS_CONFIG = XSSConfig()]
n13[DEFAULT_IDOR_CONFIG = IDORConfig()]
n14[CONSERVATIVE_STRATEGY = DetectionStrategy(De...]
n15[BALANCED_STRATEGY = DetectionStrategy(De...]
n16[AGGRESSIVE_STRATEGY = DetectionStrategy(De...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
514. function common unified smart detection manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.module_name = module_name]
n4[self.config = config]
n5[self.timeout_manager = AdaptiveTimeoutManag...]
n6[self.rate_limiter = RateLimiter(config.r...]
n7[self.early_stop = EarlyStopController(...]
n8[self.progress: ProgressTracker | None = None]
n9[self.metrics = DetectionMetrics()]
n10[self.protection_detector = ProtectionDetector()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.module_name = module_name]
n4[self.config = config]
n5[self.timeout_manager = AdaptiveTimeoutManag...]
n6[self.rate_limiter = RateLimiter(config.r...]
n7[self.early_stop = EarlyStopController(...]
n8[self.progress: ProgressTracker | None = None]
n9[self.metrics = DetectionMetrics()]
n10[self.protection_detector = ProtectionDetector()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
515. function common unified smart detection manager Function avg response time
flowchart TB
n1([開始])
n2([結束])
n3['平均回應時間']
n4{if self.successful_requests == 0}
n5[return 0.0]
n6[]
n7[return self.total_time / self.success...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;平均回應時間&#39;]
n4{if self.successful_requests == 0}
n5[return 0.0]
n6[]
n7[return self.total_time / self.success...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
516. function common unified smart detection manager Function force stop
flowchart TB
n1([開始])
n2([結束])
n3['強制停止檢測']
n4[self.early_stop.force_stop(reason)]
n5{if self.progress}
n6[logger.info(f'{self.module_name}...]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;強制停止檢測&#39;]
n4[self.early_stop.force_stop(reason)]
n5{if self.progress}
n6[logger.info(f&#39;{self.module_name}...]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
517. function common unified smart detection manager Function get performance summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取性能摘要報告']
n4[return f'\n{self.module_name} 檢測完成統...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取性能摘要報告&#39;]
n4[return f&#39;\n{self.module_name} 檢測完成統...]
n1 --> n3
n3 --> n4
n4 --> n2
518. function common unified smart detection manager Function get timeout
flowchart TB
n1([開始])
n2([結束])
n3['獲取當前應該使用的超時時間']
n4{if self.failure_count > 3}
n5[failure_multiplier = 1 + (self.failure_co...]
n6[adaptive_timeout = min(self.max_timeout...]
n7[return adaptive_timeout]
n8[]
n9{if len(self.recent_response_ti...}
n10[avg_time = sum(self.recent_resp...]
n11[adaptive_timeout = max(self.base_timeou...]
n12[return adaptive_timeout]
n13[]
n14[return self.base_timeout]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取當前應該使用的超時時間&#39;]
n4{if self.failure_count &gt; 3}
n5[failure_multiplier = 1 + (self.failure_co...]
n6[adaptive_timeout = min(self.max_timeout...]
n7[return adaptive_timeout]
n8[]
n9{if len(self.recent_response_ti...}
n10[avg_time = sum(self.recent_resp...]
n11[adaptive_timeout = max(self.base_timeou...]
n12[return adaptive_timeout]
n13[]
n14[return self.base_timeout]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
519. function common unified smart detection manager Function on rate limit detected
flowchart TB
n1([開始])
n2([結束])
n3['檢測到速率限制時的處理']
n4[self.consecutive_rate_limits += 1]
n5[self.adaptive_factor = min(5.0, self.adapti...]
n6[logger.warning(f'檢測到速率限制 (連續{sel...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測到速率限制時的處理&#39;]
n4[self.consecutive_rate_limits += 1]
n5[self.adaptive_factor = min(5.0, self.adapti...]
n6[logger.warning(f&#39;檢測到速率限制 (連續{sel...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
520. function common unified smart detection manager Function on success
flowchart TB
n1([開始])
n2([結束])
n3['成功請求時逐步恢復正常速率']
n4{if self.consecutive_rate_limit...}
n5[self.consecutive_rate_limits = max(0, self.consecut...]
n6[]
n7[self.adaptive_factor = max(1.0, self.adapti...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;成功請求時逐步恢復正常速率&#39;]
n4{if self.consecutive_rate_limit...}
n5[self.consecutive_rate_limits = max(0, self.consecut...]
n6[]
n7[self.adaptive_factor = max(1.0, self.adapti...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
521. function common unified smart detection manager Function on test failure
flowchart TB
n1([開始])
n2([結束])
n3['記錄測試失敗']
n4[self.consecutive_failures += 1]
n5[self.total_tests += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄測試失敗&#39;]
n4[self.consecutive_failures += 1]
n5[self.total_tests += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
522. function common unified smart detection manager Function on test success no vuln
flowchart TB
n1([開始])
n2([結束])
n3['記錄測試成功但無漏洞']
n4[self.consecutive_failures = 0]
n5[self.total_tests += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄測試成功但無漏洞&#39;]
n4[self.consecutive_failures = 0]
n5[self.total_tests += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
523. function common unified smart detection manager Function on timeout
flowchart TB
n1([開始])
n2([結束])
n3['記錄超時失敗']
n4[self.failure_count += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄超時失敗&#39;]
n4[self.failure_count += 1]
n1 --> n3
n3 --> n4
n4 --> n2
524. function common unified smart detection manager Function on vulnerability found
flowchart TB
n1([開始])
n2([結束])
n3['記錄發現漏洞']
n4[self.vulnerabilities_found += 1]
n5[self.consecutive_failures = 0]
n6[logger.info(f'發現漏洞 #{self.vulner...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄發現漏洞&#39;]
n4[self.vulnerabilities_found += 1]
n5[self.consecutive_failures = 0]
n6[logger.info(f&#39;發現漏洞 #{self.vulner...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
525. function common unified smart detection manager Function report vulnerability found
flowchart TB
n1([開始])
n2([結束])
n3['報告發現漏洞']
n4[self.early_stop.on_vulnerability_found()]
n5[self.metrics.vulnerabilities_found += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;報告發現漏洞&#39;]
n4[self.early_stop.on_vulnerability_found()]
n5[self.metrics.vulnerabilities_found += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
526. function common unified smart detection manager Function should continue testing
flowchart TB
n1([開始])
n2([結束])
n3['檢查是否應該繼續測試']
n4[return self.early_stop.should_continu...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查是否應該繼續測試&#39;]
n4[return self.early_stop.should_continu...]
n1 --> n3
n3 --> n4
n4 --> n2
527. function common unified smart detection manager Function should continue
flowchart TB
n1([開始])
n2([結束])
n3['判斷是否應該繼續檢測']
n4{if self.should_stop}
n5[return False]
n6[]
n7{if self.vulnerabilities_found ...}
n8[logger.info(f'已發現 {self.vulnerabilit...]
n9[self.should_stop = True]
n10[return False]
n11[]
n12{if self.consecutive_failures >...}
n13[logger.warning(f'連續失敗 {self.consecut...]
n14[self.should_stop = True]
n15[return False]
n16[]
n17[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;判斷是否應該繼續檢測&#39;]
n4{if self.should_stop}
n5[return False]
n6[]
n7{if self.vulnerabilities_found ...}
n8[logger.info(f&#39;已發現 {self.vulnerabilit...]
n9[self.should_stop = True]
n10[return False]
n11[]
n12{if self.consecutive_failures &gt;...}
n13[logger.warning(f&#39;連續失敗 {self.consecut...]
n14[self.should_stop = True]
n15[return False]
n16[]
n17[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
528. function common unified smart detection manager Function start detection
flowchart TB
n1([開始])
n2([結束])
n3['開始檢測並初始化進度追蹤']
n4[self.progress = ProgressTracker(tota...]
n5[logger.info(f'開始 {self.module_name...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;開始檢測並初始化進度追蹤&#39;]
n4[self.progress = ProgressTracker(tota...]
n5[logger.info(f&#39;開始 {self.module_name&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
529. function common unified smart detection manager Function success rate
flowchart TB
n1([開始])
n2([結束])
n3['成功率']
n4{if self.total_requests == 0}
n5[return 0.0]
n6[]
n7[return self.successful_requests / sel...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;成功率&#39;]
n4{if self.total_requests == 0}
n5[return 0.0]
n6[]
n7[return self.successful_requests / sel...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
530. function common unified smart detection manager Function update progress
flowchart TB
n1([開始])
n2([結束])
n3['更新進度']
n4{if self.progress}
n5[self.progress.update(description, force_update)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新進度&#39;]
n4{if self.progress}
n5[self.progress.update(description, force_update)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
531. function common unified smart detection manager Function update
flowchart TB
n1([開始])
n2([結束])
n3['更新進度']
n4[self.current_step += 1]
n5[now = time.time()]
n6{if not force_update and now - ...}
n7[return]
n8[]
n9[elapsed = now - self.start_tim...]
n10[progress_percent = self.current_step / ...]
n11{if self.current_step > 0 and s...}
n12[avg_time_per_step = elapsed / self.curre...]
n13[remaining_steps = self.total_steps - s...]
n14[eta = remaining_steps * av...]
n15[logger.info(f'{self.task_name}:...]
n16{if self.current_step >= self.t...}
n17[total_time = elapsed]
n18[logger.info(f'{self.task_name} ...]
n19[]
n20[]
n21[self.last_update_time = now]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n20
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新進度&#39;]
n4[self.current_step += 1]
n5[now = time.time()]
n6{if not force_update and now - ...}
n7[return]
n8[]
n9[elapsed = now - self.start_tim...]
n10[progress_percent = self.current_step / ...]
n11{if self.current_step &gt; 0 and s...}
n12[avg_time_per_step = elapsed / self.curre...]
n13[remaining_steps = self.total_steps - s...]
n14[eta = remaining_steps * av...]
n15[logger.info(f&#39;{self.task_name}:...]
n16{if self.current_step &gt;= self.t...}
n17[total_time = elapsed]
n18[logger.info(f&#39;{self.task_name} ...]
n19[]
n20[]
n21[self.last_update_time = now]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n20
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
532. function common unified smart detection manager Module
flowchart TB
n1([開始])
n2([結束])
n3['\n統一智能檢測管理器 - 基於 SQLi 模組成功經驗\n為所有功能模組提供統一的智能...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from collections.abc import Callable]
n7[from dataclasses import dataclass]
n8[import time]
n9[from typing import Any]
n10[from services.aiva_common.utils import get_logger]
n11[from .detection_config import BaseDetectionConfig]
n12[logger = get_logger(__name__)]
n13[class DetectionMetrics(...)]
n14[class AdaptiveTimeoutManager(...)]
n15[class RateLimiter(...)]
n16[class EarlyStopController(...)]
n17[class ProgressTracker(...)]
n18[class ProtectionDetector(...)]
n19[class UnifiedSmartDetectionManager(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n統一智能檢測管理器 - 基於 SQLi 模組成功經驗\n為所有功能模組提供統一的智能...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from collections.abc import Callable]
n7[from dataclasses import dataclass]
n8[import time]
n9[from typing import Any]
n10[from services.aiva_common.utils import get_logger]
n11[from .detection_config import BaseDetectionConfig]
n12[logger = get_logger(__name__)]
n13[class DetectionMetrics(...)]
n14[class AdaptiveTimeoutManager(...)]
n15[class RateLimiter(...)]
n16[class EarlyStopController(...)]
n17[class ProgressTracker(...)]
n18[class ProtectionDetector(...)]
n19[class UnifiedSmartDetectionManager(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
533. function common worker statistics Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化統計數據收集器\n\n Args:\n ...]
n4[self.stats = WorkerStatistics(tas...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化統計數據收集器\n\n Args:\n ...]
n4[self.stats = WorkerStatistics(tas...]
n1 --> n3
n3 --> n4
n4 --> n2
534. function common worker statistics Function add error
flowchart TB
n1([開始])
n2([結束])
n3['添加錯誤記錄']
n4[self.error_count += 1]
n5[category_key = error.category.value]
n6[self.errors_by_category[category_key] = self.erro...]
n7[self.error_details.append(error.to_dict())]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加錯誤記錄&#39;]
n4[self.error_count += 1]
n5[category_key = error.category.value]
n6[self.errors_by_category[category_key] = self.erro...]
n7[self.error_details.append(error.to_dict())]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
535. function common worker statistics Function add oast callback
flowchart TB
n1([開始])
n2([結束])
n3['添加 OAST 回調記錄']
n4[self.oast_callbacks_received += 1]
n5[self.oast_callback_details.append(callback.to_dict...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加 OAST 回調記錄&#39;]
n4[self.oast_callbacks_received += 1]
n5[self.oast_callback_details.append(callback.to_dict...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
536. function common worker statistics Function finalize
flowchart TB
n1([開始])
n2([結束])
n3['完成統計並返回']
n4[self.stats.finalize()]
n5[return self.stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;完成統計並返回&#39;]
n4[self.stats.finalize()]
n5[return self.stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
537. function common worker statistics Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計數據']
n4[return self.stats]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計數據&#39;]
n4[return self.stats]
n1 --> n3
n3 --> n4
n4 --> n2
538. function common worker statistics Function get summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取摘要報告']
n4[return self.stats.to_summary()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取摘要報告&#39;]
n4[return self.stats.to_summary()]
n1 --> n3
n3 --> n4
n4 --> n2
539. function common worker statistics Function record early stopping
flowchart TB
n1([開始])
n2([結束])
n3['記錄 Early Stopping']
n4[record = EarlyStoppingRecord(...]
n5[self.stats.record_early_stopping(record)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 Early Stopping&#39;]
n4[record = EarlyStoppingRecord(...]
n5[self.stats.record_early_stopping(record)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
540. function common worker statistics Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤']
n4[error = ErrorRecord(category...]
n5[self.stats.add_error(error)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤&#39;]
n4[error = ErrorRecord(category...]
n5[self.stats.add_error(error)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
541. function common worker statistics Function record oast callback
flowchart TB
n1([開始])
n2([結束])
n3['記錄 OAST 回調']
n4[callback = OastCallbackRecord(p...]
n5[self.stats.add_oast_callback(callback)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 OAST 回調&#39;]
n4[callback = OastCallbackRecord(p...]
n5[self.stats.add_oast_callback(callback)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
542. function common worker statistics Function record oast probe
flowchart TB
n1([開始])
n2([結束])
n3['記錄 OAST 探針發送']
n4[self.stats.oast_probes_sent += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 OAST 探針發送&#39;]
n4[self.stats.oast_probes_sent += 1]
n1 --> n3
n3 --> n4
n4 --> n2
543. function common worker statistics Function record payload test
flowchart TB
n1([開始])
n2([結束])
n3['記錄 Payload 測試']
n4[self.stats.payloads_tested += 1]
n5{if success}
n6[self.stats.payloads_succeeded += 1]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 Payload 測試&#39;]
n4[self.stats.payloads_tested += 1]
n5{if success}
n6[self.stats.payloads_succeeded += 1]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
544. function common worker statistics Function record request
flowchart TB
n1([開始])
n2([結束])
n3['記錄請求']
n4[self.stats.total_requests += 1]
n5{if success}
n6[self.stats.successful_requests += 1]
n7[self.stats.failed_requests += 1]
n8[]
n9{if timeout}
n10[self.stats.timeout_requests += 1]
n11[]
n12{if rate_limited}
n13[self.stats.rate_limited_requests += 1]
n14[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄請求&#39;]
n4[self.stats.total_requests += 1]
n5{if success}
n6[self.stats.successful_requests += 1]
n7[self.stats.failed_requests += 1]
n8[]
n9{if timeout}
n10[self.stats.timeout_requests += 1]
n11[]
n12{if rate_limited}
n13[self.stats.rate_limited_requests += 1]
n14[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n2
545. function common worker statistics Function record vulnerability
flowchart TB
n1([開始])
n2([結束])
n3['記錄漏洞發現']
n4{if false_positive}
n5[self.stats.false_positives_filtered += 1]
n6[self.stats.vulnerabilities_found += 1]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n7
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄漏洞發現&#39;]
n4{if false_positive}
n5[self.stats.false_positives_filtered += 1]
n6[self.stats.vulnerabilities_found += 1]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n7
n6 --> n7
n7 --> n2
546. function common worker statistics Function set adaptive behavior
flowchart TB
n1([開始])
n2([結束])
n3['設置自適應行為標記']
n4{if adaptive_timeout}
n5[self.stats.adaptive_timeout_used = True]
n6[self.stats.timeout_adjustments += 1]
n7[]
n8{if rate_limiting}
n9[self.stats.rate_limiting_applied = True]
n10[]
n11{if protection_detected}
n12[self.stats.protection_detected = True]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置自適應行為標記&#39;]
n4{if adaptive_timeout}
n5[self.stats.adaptive_timeout_used = True]
n6[self.stats.timeout_adjustments += 1]
n7[]
n8{if rate_limiting}
n9[self.stats.rate_limiting_applied = True]
n10[]
n11{if protection_detected}
n12[self.stats.protection_detected = True]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n2
547. function common worker statistics Function set module specific
flowchart TB
n1([開始])
n2([結束])
n3['設置模組特定統計數據']
n4[self.stats.module_specific[key] = value]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置模組特定統計數據&#39;]
n4[self.stats.module_specific[key] = value]
n1 --> n3
n3 --> n4
n4 --> n2
548. function common worker statistics Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典格式']
n4[return {'reason': self.reaso...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典格式&#39;]
n4[return {&#39;reason&#39;: self.reaso...]
n1 --> n3
n3 --> n4
n4 --> n2
549. function common worker statistics Function to summary
flowchart TB
n1([開始])
n2([結束])
n3['生成摘要報告']
n4[success_rate = self.successful_requ...]
n5[payload_success_rate = self.payloads_succee...]
n6[oast_success_rate = self.oast_callbacks_...]
n7[return {'task_id': self.task...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成摘要報告&#39;]
n4[success_rate = self.successful_requ...]
n5[payload_success_rate = self.payloads_succee...]
n6[oast_success_rate = self.oast_callbacks_...]
n7[return {&#39;task_id&#39;: self.task...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
550. function common worker statistics Module
flowchart TB
n1([開始])
n2([結束])
n3['\nEnhanced Worker 統計數據收集模組\n\n提供統一的統計數據 Sche...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from datetime import UTC, datetime]
n7[from enum import Enum]
n8[from typing import Any]
n9[from pydantic import BaseModel, Field]
n10[class ErrorCategory(...)]
n11[class StoppingReason(...)]
n12[class ErrorRecord(...)]
n13[class OastCallbackRecord(...)]
n14[class EarlyStoppingRecord(...)]
n15[class WorkerStatistics(...)]
n16[class StatisticsCollector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nEnhanced Worker 統計數據收集模組\n\n提供統一的統計數據 Sche...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from datetime import UTC, datetime]
n7[from enum import Enum]
n8[from typing import Any]
n9[from pydantic import BaseModel, Field]
n10[class ErrorCategory(...)]
n11[class StoppingReason(...)]
n12[class ErrorRecord(...)]
n13[class OastCallbackRecord(...)]
n14[class EarlyStoppingRecord(...)]
n15[class WorkerStatistics(...)]
n16[class StatisticsCollector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
551. function function idor aiva func idor init Module
flowchart TB
n1([開始])
n2([結束])
n3['\nAIVA Function IDOR - Insecure Direct Objec...]
n4[__version__ = '0.1.0']
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nAIVA Function IDOR - Insecure Direct Objec...]
n4[__version__ = &#39;0.1.0&#39;]
n1 --> n3
n3 --> n4
n4 --> n2
552. function function idor aiva func idor cross user tester Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.client = client]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.client = client]
n1 --> n3
n3 --> n2
553. function function idor aiva func idor cross user tester Module
flowchart TB
n1([開始])
n2([結束])
n3['\nCross User Tester for IDOR Detection\n\nIm...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[import re]
n7[import httpx]
n8[from pydantic import HttpUrl]
n9[from services.aiva_common.schemas import FunctionT...]
n10[class CrossUserTestResult(...)]
n11[class CrossUserTester(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nCross User Tester for IDOR Detection\n\nIm...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[import re]
n7[import httpx]
n8[from pydantic import HttpUrl]
n9[from services.aiva_common.schemas import FunctionT...]
n10[class CrossUserTestResult(...)]
n11[class CrossUserTester(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
554. function function idor aiva func idor enhanced worker Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化增強版 IDOR 工作器\n\n Args:\n...]
n4[self.config = config or IDORConfig...]
n5[self.smart_detector = SmartIDORDetector(se...]
n6[logger.info('Enhanced IDOR Worker initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化增強版 IDOR 工作器\n\n Args:\n...]
n4[self.config = config or IDORConfig...]
n5[self.smart_detector = SmartIDORDetector(se...]
n6[logger.info(&#39;Enhanced IDOR Worker initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
555. function function idor aiva func idor enhanced worker Function convert to finding payloads
flowchart TB
n1([開始])
n2([結束])
n3['\n 轉換檢測結果為 FindingPayload 對象\n\n ...]
n4[findings = []]
n5{for finding_data in findings_data}
n6[finding_payload = FindingPayload(findi...]
n7[findings.append(finding_payload)]
n8[]
n9[return findings]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 轉換檢測結果為 FindingPayload 對象\n\n ...]
n4[findings = []]
n5{for finding_data in findings_data}
n6[finding_payload = FindingPayload(findi...]
n7[findings.append(finding_payload)]
n8[]
n9[return findings]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
556. function function idor aiva func idor enhanced worker Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細信息字典']
n4[details: dict[str, Any] = {'atte...]
n5{if self.errors}
n6[details['errors'] = self....]
n7[]
n8[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細信息字典&#39;]
n4[details: dict[str, Any] = {&#39;atte...]
n5{if self.errors}
n6[details[&#39;errors&#39;] = self....]
n7[]
n8[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
557. function function idor aiva func idor enhanced worker Module
flowchart TB
n1([開始])
n2([結束])
n3['\nEnhanced IDOR Worker - 增強版 IDOR 工作器\n整合智能檢...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[import httpx]
n8[from services.aiva_common.enums import Topic]
n9[from services.aiva_common.mq import get_broker]
n10[from services.aiva_common.schemas import AivaMessa...]
n11[from services.aiva_common.utils import get_logger]
n12[from services.function.common.detection_config imp...]
n13[from services.function.common.worker_statistics im...]
n14[from .cross_user_tester import CrossUserTester]
n15[from .resource_id_extractor import ResourceIdExtra...]
n16[from .smart_idor_detector import SmartIDORDetector]
n17[from .vertical_escalation_tester import VerticalEs...]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 15.0]
n20[class EnhancedIdorTelemetry(...)]
n21[class EnhancedIdorTaskExecutionResult(...)]
n22[class EnhancedIDORWorker(...)]
n23[def run(...)]
n24[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nEnhanced IDOR Worker - 增強版 IDOR 工作器\n整合智能檢...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[import httpx]
n8[from services.aiva_common.enums import Topic]
n9[from services.aiva_common.mq import get_broker]
n10[from services.aiva_common.schemas import AivaMessa...]
n11[from services.aiva_common.utils import get_logger]
n12[from services.function.common.detection_config imp...]
n13[from services.function.common.worker_statistics im...]
n14[from .cross_user_tester import CrossUserTester]
n15[from .resource_id_extractor import ResourceIdExtra...]
n16[from .smart_idor_detector import SmartIDORDetector]
n17[from .vertical_escalation_tester import VerticalEs...]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 15.0]
n20[class EnhancedIdorTelemetry(...)]
n21[class EnhancedIdorTaskExecutionResult(...)]
n22[class EnhancedIDORWorker(...)]
n23[def run(...)]
n24[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
558. function function idor aiva func idor resource id extractor Function extract from url
flowchart TB
n1([開始])
n2([結束])
n3['\n Extract resource IDs from URL path...]
n4[ids: list[ResourceId] = []]
n5[path = url.split('?')[...]
n6[path_parts = path.split('/')]
n7{for part in path_parts}
n8{if not part}
n9[continue]
n10[]
n11{for (pattern_name, regex) in self.PATTERNS.ite...}
n12{if re.fullmatch(regex, part, r...}
n13[ids.append(ResourceId(value=part, pattern=pattern...]
n14[break]
n15[]
n16[]
n17[]
n18{if '?' in url}
n19[query = url.split('?', 1)...]
n20{for param in query.split('&&#...}
n21{if '=' not in param}
n22[continue]
n23[]
n24[(key, value) = param.split('=&...]
n25{for (pattern_name, regex) in self.PATTERNS.ite...}
n26{if re.fullmatch(regex, value, ...}
n27[ids.append(ResourceId(value=value, pattern=patter...]
n28[break]
n29[]
n30[]
n31[]
n32[]
n33[return ids]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n17
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n11
n16 --> n7
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n32
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n31
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n30
n26 -->|Yes| n27
n26 -->|No| n29
n27 --> n28
n28 --> n29
n29 --> n25
n30 --> n20
n31 --> n32
n32 --> n33
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Extract resource IDs from URL path...]
n4[ids: list[ResourceId] = []]
n5[path = url.split(&#39;?&#39;)[...]
n6[path_parts = path.split(&#39;/&#39;)]
n7{for part in path_parts}
n8{if not part}
n9[continue]
n10[]
n11{for (pattern_name, regex) in self.PATTERNS.ite...}
n12{if re.fullmatch(regex, part, r...}
n13[ids.append(ResourceId(value=part, pattern=pattern...]
n14[break]
n15[]
n16[]
n17[]
n18{if &#39;?&#39; in url}
n19[query = url.split(&#39;?&#39;, 1)...]
n20{for param in query.split(&#39;&&#...}
n21{if &#39;=&#39; not in param}
n22[continue]
n23[]
n24[(key, value) = param.split(&#39;=&...]
n25{for (pattern_name, regex) in self.PATTERNS.ite...}
n26{if re.fullmatch(regex, value, ...}
n27[ids.append(ResourceId(value=value, pattern=patter...]
n28[break]
n29[]
n30[]
n31[]
n32[]
n33[return ids]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n17
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n11
n16 --> n7
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n32
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n31
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n30
n26 -->|Yes| n27
n26 -->|No| n29
n27 --> n28
n28 --> n29
n29 --> n25
n30 --> n20
n31 --> n32
n32 --> n33
n33 --> n2
559. function function idor aiva func idor resource id extractor Function generate test ids
flowchart TB
n1([開始])
n2([結束])
n3['\n Generate test ID variations based ...]
n4[test_ids: list[str] = []]
n5{if original_id.pattern == 'num...}
n6[try]
n7[base = int(original_id.valu...]
n8[offsets = [-2, -1, 1, 2, 10, 1...]
n9{for offset in offsets}
n10[new_id = base + offset]
n11{if new_id > 0}
n12[test_ids.append(str(new_id))]
n13[]
n14{if len(test_ids) >= count}
n15[break]
n16[]
n17[]
n18[]
n19[except ValueError]
n20[pass]
n21{if original_id.pattern == 'uuid'}
n22[import random]
n23[parts = original_id.value.sp...]
n24{for _ in range(count)}
n25[modified = parts.copy()]
n26[modified[0] = f'{random.randint&...]
n27[test_ids.append('-'.join(...]
n28[]
n29{if original_id.pattern == 'hash'}
n30[import hashlib]
n31[import random]
n32[length = len(original_id.valu...]
n33{for i in range(count)}
n34[random_str = f'test_{random.randi...]
n35{if length == 32}
n36[test_hash = hashlib.md5(random_s...]
n37[test_hash = hashlib.sha256(rando...]
n38[]
n39[test_ids.append(test_hash)]
n40[]
n41{if original_id.pattern == 'mixed'}
n42[import random]
n43[unique_ids: set[str] = set()]
n44[attempts = 0]
n45[max_attempts = count * 10]
n46{while len(unique_ids) < coun...}
n47[result = '']
n48{for char in original_id.value}
n49{if char.isdigit()}
n50[result += str(random.randint(0, 9))]
n51[result += char]
n52[]
n53[]
n54{if result != original_id.value}
n55[unique_ids.add(result)]
n56[]
n57[attempts += 1]
n58[]
n59[test_ids.extend(list(unique_ids))]
n60[]
n61[]
n62[]
n63[]
n64[return test_ids[:count]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n21
n6 --> n7
n6 --> n19
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n17
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n9
n17 --> n18
n18 --> n63
n19 --> n20
n20 --> n18
n21 -->|Yes| n22
n21 -->|No| n29
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n28
n25 --> n26
n26 --> n27
n27 --> n24
n28 --> n62
n29 -->|Yes| n30
n29 -->|No| n41
n30 --> n31
n31 --> n32
n32 --> n33
n33 -->|Yes| n34
n33 -->|No| n40
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n37
n36 --> n38
n37 --> n38
n38 --> n39
n39 --> n33
n40 --> n61
n41 -->|Yes| n42
n41 -->|No| n60
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n46
n46 -->|Yes| n47
n46 -->|No| n58
n47 --> n48
n48 -->|Yes| n49
n48 -->|No| n53
n49 -->|Yes| n50
n49 -->|No| n51
n50 --> n52
n51 --> n52
n52 --> n48
n53 --> n54
n54 -->|Yes| n55
n54 -->|No| n56
n55 --> n56
n56 --> n57
n57 --> n46
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 --> n64
n64 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Generate test ID variations based ...]
n4[test_ids: list[str] = []]
n5{if original_id.pattern == &#39;num...}
n6[try]
n7[base = int(original_id.valu...]
n8[offsets = [-2, -1, 1, 2, 10, 1...]
n9{for offset in offsets}
n10[new_id = base + offset]
n11{if new_id &gt; 0}
n12[test_ids.append(str(new_id))]
n13[]
n14{if len(test_ids) &gt;= count}
n15[break]
n16[]
n17[]
n18[]
n19[except ValueError]
n20[pass]
n21{if original_id.pattern == &#39;uuid&#39;}
n22[import random]
n23[parts = original_id.value.sp...]
n24{for _ in range(count)}
n25[modified = parts.copy()]
n26[modified[0] = f&#39;{random.randint&...]
n27[test_ids.append(&#39;-&#39;.join(...]
n28[]
n29{if original_id.pattern == &#39;hash&#39;}
n30[import hashlib]
n31[import random]
n32[length = len(original_id.valu...]
n33{for i in range(count)}
n34[random_str = f&#39;test_{random.randi...]
n35{if length == 32}
n36[test_hash = hashlib.md5(random_s...]
n37[test_hash = hashlib.sha256(rando...]
n38[]
n39[test_ids.append(test_hash)]
n40[]
n41{if original_id.pattern == &#39;mixed&#39;}
n42[import random]
n43[unique_ids: set[str] = set()]
n44[attempts = 0]
n45[max_attempts = count * 10]
n46{while len(unique_ids) &lt; coun...}
n47[result = &#39;&#39;]
n48{for char in original_id.value}
n49{if char.isdigit()}
n50[result += str(random.randint(0, 9))]
n51[result += char]
n52[]
n53[]
n54{if result != original_id.value}
n55[unique_ids.add(result)]
n56[]
n57[attempts += 1]
n58[]
n59[test_ids.extend(list(unique_ids))]
n60[]
n61[]
n62[]
n63[]
n64[return test_ids[:count]]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n21
n6 --> n7
n6 --> n19
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n17
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n9
n17 --> n18
n18 --> n63
n19 --> n20
n20 --> n18
n21 -->|Yes| n22
n21 -->|No| n29
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n28
n25 --> n26
n26 --> n27
n27 --> n24
n28 --> n62
n29 -->|Yes| n30
n29 -->|No| n41
n30 --> n31
n31 --> n32
n32 --> n33
n33 -->|Yes| n34
n33 -->|No| n40
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n37
n36 --> n38
n37 --> n38
n38 --> n39
n39 --> n33
n40 --> n61
n41 -->|Yes| n42
n41 -->|No| n60
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n46
n46 -->|Yes| n47
n46 -->|No| n58
n47 --> n48
n48 -->|Yes| n49
n48 -->|No| n53
n49 -->|Yes| n50
n49 -->|No| n51
n50 --> n52
n51 --> n52
n52 --> n48
n53 --> n54
n54 -->|Yes| n55
n54 -->|No| n56
n55 --> n56
n56 --> n57
n57 --> n46
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 --> n64
n64 --> n2
560. function function idor aiva func idor resource id extractor Function replace id in url
flowchart TB
n1([開始])
n2([結束])
n3['\n Replace an ID in URL with a new ID...]
n4[from urllib.parse import parse_qsl, urlencode, url...]
n5[parsed = urlparse(url)]
n6[path_parts = parsed.path.split('/...]
n7[path_parts = [new_id if part == o...]
n8[new_path = '/'.join(path_part...]
n9[query_params = parse_qsl(parsed.que...]
n10[new_query_params = [(k, new_id if v == ...]
n11[new_query = urlencode(new_query_...]
n12[new_url = urlunparse((parsed.s...]
n13[return new_url]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Replace an ID in URL with a new ID...]
n4[from urllib.parse import parse_qsl, urlencode, url...]
n5[parsed = urlparse(url)]
n6[path_parts = parsed.path.split(&#39;/...]
n7[path_parts = [new_id if part == o...]
n8[new_path = &#39;/&#39;.join(path_part...]
n9[query_params = parse_qsl(parsed.que...]
n10[new_query_params = [(k, new_id if v == ...]
n11[new_query = urlencode(new_query_...]
n12[new_url = urlunparse((parsed.s...]
n13[return new_url]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
561. function function idor aiva func idor resource id extractor Module
flowchart TB
n1([開始])
n2([結束])
n3['\nResource ID Extractor\n\nExtracts resource...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[import re]
n7[from typing import Literal]
n8[IdPattern = Literal['numeric'...]
n9[class ResourceId(...)]
n10[class ResourceIdExtractor(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nResource ID Extractor\n\nExtracts resource...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[import re]
n7[from typing import Literal]
n8[IdPattern = Literal[&#39;numeric&#39;...]
n9[class ResourceId(...)]
n10[class ResourceIdExtractor(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
562. function function idor aiva func idor schemas Function analyze predictability
flowchart TB
n1([開始])
n2([結束])
n3['分析 ID 可預測性 (0.0-1.0, 1.0 = 完全可預測)&am...]
n4{if self.sequential_pattern}
n5[return 1.0]
n6[]
n7{if self.predictable_ids}
n8[return 0.8]
n9[]
n10{if self.min_id_value and self....}
n11[range_size = self.max_id_value - ...]
n12{if range_size < 1000}
n13[return 0.9]
n14{if range_size < 10000}
n15[return 0.6]
n16[return 0.3]
n17[]
n18[]
n19[]
n20[return 0.0]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n19
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n18
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析 ID 可預測性 (0.0-1.0, 1.0 = 完全可預測)&am...]
n4{if self.sequential_pattern}
n5[return 1.0]
n6[]
n7{if self.predictable_ids}
n8[return 0.8]
n9[]
n10{if self.min_id_value and self....}
n11[range_size = self.max_id_value - ...]
n12{if range_size &lt; 1000}
n13[return 0.9]
n14{if range_size &lt; 10000}
n15[return 0.6]
n16[return 0.3]
n17[]
n18[]
n19[]
n20[return 0.0]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n19
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n18
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
563. function function idor aiva func idor schemas Function get severity score
flowchart TB
n1([開始])
n2([結束])
n3['計算嚴重程度評分 (0.0-1.0)']
n4[score = 0.0]
n5{if self.vulnerable}
n6[score += 0.3]
n7[]
n8{if self.access_granted}
n9[score += 0.4]
n10[]
n11{if self.data_leaked}
n12[score += 0.3]
n13[]
n14{if self.response_similarity > 0.8}
n15[score += 0.2]
n16[]
n17[return min(score * self.confidence, 1...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算嚴重程度評分 (0.0-1.0)&#39;]
n4[score = 0.0]
n5{if self.vulnerable}
n6[score += 0.3]
n7[]
n8{if self.access_granted}
n9[score += 0.4]
n10[]
n11{if self.data_leaked}
n12[score += 0.3]
n13[]
n14{if self.response_similarity &gt; 0.8}
n15[score += 0.2]
n16[]
n17[return min(score * self.confidence, 1...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
564. function function idor aiva func idor schemas Function get success rate
flowchart TB
n1([開始])
n2([結束])
n3['獲取成功率']
n4{if self.vectors_tested == 0}
n5[return 0.0]
n6[]
n7[return self.successful_bypasses / sel...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取成功率&#39;]
n4{if self.vectors_tested == 0}
n5[return 0.0]
n6[]
n7[return self.successful_bypasses / sel...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
565. function function idor aiva func idor schemas Function is successful bypass
flowchart TB
n1([開始])
n2([結束])
n3['判斷是否成功繞過權限檢查']
n4[return self.vulnerable and self.acces...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;判斷是否成功繞過權限檢查&#39;]
n4[return self.vulnerable and self.acces...]
n1 --> n3
n3 --> n4
n4 --> n2
566. function function idor aiva func idor schemas Function record vector test
flowchart TB
n1([開始])
n2([結束])
n3['記錄向量測試結果']
n4[self.vectors_tested += 1]
n5{if result.vulnerable}
n6[self.successful_bypasses += 1]
n7[]
n8{if result.data_leaked}
n9[self.data_leakages += 1]
n10[]
n11{if result.access_granted}
n12[self.authorization_bypasses += 1]
n13[]
n14[resource_type = result.test_vector.r...]
n15{if resource_type not in self.r...}
n16[self.resource_types_found.append(resource_type)]
n17[]
n18[id_pattern = result.test_vector.i...]
n19[self.id_patterns_detected[id_pattern] = self.id_p...]
n20{if self.vectors_tested == 1}
n21[self.average_response_time_ms = result.execution_tim...]
n22[self.average_response_time_ms = (self.average_respon...]
n23[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n23
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄向量測試結果&#39;]
n4[self.vectors_tested += 1]
n5{if result.vulnerable}
n6[self.successful_bypasses += 1]
n7[]
n8{if result.data_leaked}
n9[self.data_leakages += 1]
n10[]
n11{if result.access_granted}
n12[self.authorization_bypasses += 1]
n13[]
n14[resource_type = result.test_vector.r...]
n15{if resource_type not in self.r...}
n16[self.resource_types_found.append(resource_type)]
n17[]
n18[id_pattern = result.test_vector.i...]
n19[self.id_patterns_detected[id_pattern] = self.id_p...]
n20{if self.vectors_tested == 1}
n21[self.average_response_time_ms = result.execution_tim...]
n22[self.average_response_time_ms = (self.average_respon...]
n23[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n23
n22 --> n23
n23 --> n2
567. function function idor aiva func idor schemas Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式']
n4[details = super().to_details(f...]
n5[details.update({'vectors_tested&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式&#39;]
n4[details = super().to_details(f...]
n5[details.update({&#39;vectors_tested&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
568. function function idor aiva func idor schemas Function validate method
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 方法']
n4[allowed = {'GET', &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f'Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 方法&#39;]
n4[allowed = {&#39;GET&#39;, &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f&#39;Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
569. function function idor aiva func idor schemas Function validate pattern
flowchart TB
n1([開始])
n2([結束])
n3['驗證 ID 模式']
n4[allowed = {'numeric', &&...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid ID pattern: ...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 ID 模式&#39;]
n4[allowed = {&#39;numeric&#39;, &&...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid ID pattern: &#...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
570. function function idor aiva func idor schemas Function validate resource type
flowchart TB
n1([開始])
n2([結束])
n3['驗證資源類型']
n4{if not v or len(v.strip()) == 0}
n5[raise ValueError('Resource type cannot be...]
n6[]
n7[return v.strip().lower()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證資源類型&#39;]
n4{if not v or len(v.strip()) == 0}
n5[raise ValueError(&#39;Resource type cannot be...]
n6[]
n7[return v.strip().lower()]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
571. function function idor aiva func idor schemas Function validate status code
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 狀態碼']
n4{if not 100 <= v < 600}
n5[raise ValueError(f'Invalid HTTP status co...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 狀態碼&#39;]
n4{if not 100 &lt;= v &lt; 600}
n5[raise ValueError(f&#39;Invalid HTTP status co...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
572. function function idor aiva func idor schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nIDOR 模組專用數據合約\n定義 IDOR (Insecure Direc...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingPa...]
n8[class IdorTestVector(...)]
n9[class IdorDetectionResult(...)]
n10[class ResourceAccessPattern(...)]
n11[class IdorTelemetry(...)]
n12[class TaskExecutionResult(...)]
n13[__all__ = ['IdorTestVector', ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nIDOR 模組專用數據合約\n定義 IDOR (Insecure Direc...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingPa...]
n8[class IdorTestVector(...)]
n9[class IdorDetectionResult(...)]
n10[class ResourceAccessPattern(...)]
n11[class IdorTelemetry(...)]
n12[class TaskExecutionResult(...)]
n13[__all__ = [&#39;IdorTestVector&#39;, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
573. function function idor aiva func idor smart idor detector Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化智能 IDOR 檢測器\n\n Args:\n ...]
n4[self.config = config or IDORConfig...]
n5[self.smart_manager = UnifiedSmartDetectio...]
n6[logger.info('Smart IDOR Detector initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化智能 IDOR 檢測器\n\n Args:\n ...]
n4[self.config = config or IDORConfig...]
n5[self.smart_manager = UnifiedSmartDetectio...]
n6[logger.info(&#39;Smart IDOR Detector initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
574. function function idor aiva func idor smart idor detector Function build horizontal finding
flowchart TB
n1([開始])
n2([結束])
n3['構建水平 IDOR 檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[return {'finding_id': new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建水平 IDOR 檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[return {&#39;finding_id&#39;: new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
575. function function idor aiva func idor smart idor detector Function build vertical finding
flowchart TB
n1([開始])
n2([結束])
n3['構建垂直 IDOR 檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[return {'finding_id': new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建垂直 IDOR 檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[return {&#39;finding_id&#39;: new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
576. function function idor aiva func idor smart idor detector Function calculate total steps
flowchart TB
n1([開始])
n2([結束])
n3['計算總檢測步驟數']
n4[steps = 1]
n5{if self.config.horizontal_esca...}
n6[steps += len(self.config.id_generation_methods) *...]
n7[]
n8{if self.config.vertical_escala...}
n9[steps += len(self.config.privilege_levels) * 2]
n10[]
n11[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算總檢測步驟數&#39;]
n4[steps = 1]
n5{if self.config.horizontal_esca...}
n6[steps += len(self.config.id_generation_methods) *...]
n7[]
n8{if self.config.vertical_escala...}
n9[steps += len(self.config.privilege_levels) * 2]
n10[]
n11[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
577. function function idor aiva func idor smart idor detector Function add error
flowchart TB
n1([開始])
n2([結束])
n3['添加錯誤']
n4[self.errors.append(error)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加錯誤&#39;]
n4[self.errors.append(error)]
n1 --> n3
n3 --> n4
n4 --> n2
578. function function idor aiva func idor smart idor detector Function add finding
flowchart TB
n1([開始])
n2([結束])
n3['添加發現的漏洞']
n4[self.findings.append(finding)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加發現的漏洞&#39;]
n4[self.findings.append(finding)]
n1 --> n3
n3 --> n4
n4 --> n2
579. function function idor aiva func idor smart idor detector Function increment attempts
flowchart TB
n1([開始])
n2([結束])
n3['增加嘗試次數']
n4[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;增加嘗試次數&#39;]
n4[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n2
580. function function idor aiva func idor smart idor detector Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSmart IDOR Detector - 智能 IDOR 檢測器\n整合統一檢測管...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[import time]
n7[from typing import Any]
n8[import httpx]
n9[from services.aiva_common.schemas import FunctionT...]
n10[from services.aiva_common.utils import get_logger]
n11[from services.function.common.detection_config imp...]
n12[from services.function.common.unified_smart_detect...]
n13[from .cross_user_tester import CrossUserTester, Cr...]
n14[from .resource_id_extractor import ResourceId, Res...]
n15[from .vertical_escalation_tester import PrivilegeL...]
n16[logger = get_logger(__name__)]
n17[class IDORDetectionContext(...)]
n18[class SmartIDORDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSmart IDOR Detector - 智能 IDOR 檢測器\n整合統一檢測管...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[import time]
n7[from typing import Any]
n8[import httpx]
n9[from services.aiva_common.schemas import FunctionT...]
n10[from services.aiva_common.utils import get_logger]
n11[from services.function.common.detection_config imp...]
n12[from services.function.common.unified_smart_detect...]
n13[from .cross_user_tester import CrossUserTester, Cr...]
n14[from .resource_id_extractor import ResourceId, Res...]
n15[from .vertical_escalation_tester import PrivilegeL...]
n16[logger = get_logger(__name__)]
n17[class IDORDetectionContext(...)]
n18[class SmartIDORDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
581. function function idor aiva func idor vertical escalation tester Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.client = client]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.client = client]
n1 --> n3
n3 --> n2
582. function function idor aiva func idor vertical escalation tester Function infer required privilege
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據 URL 推斷所需權限級別\n \n ...]
n4[url_lower = url.lower()]
n5[admin_patterns = ['/admin/', ...]
n6{for pattern in admin_patterns}
n7{if pattern in url_lower}
n8[return PrivilegeLevel.ADMIN]
n9[]
n10[]
n11[return PrivilegeLevel.USER]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n6
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據 URL 推斷所需權限級別\n \n ...]
n4[url_lower = url.lower()]
n5[admin_patterns = [&#39;/admin/&#39;, ...]
n6{for pattern in admin_patterns}
n7{if pattern in url_lower}
n8[return PrivilegeLevel.ADMIN]
n9[]
n10[]
n11[return PrivilegeLevel.USER]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n6
n10 --> n11
n11 --> n2
583. function function idor aiva func idor vertical escalation tester Module
flowchart TB
n1([開始])
n2([結束])
n3['\nVertical Escalation Tester for IDOR Detect...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[from enum import Enum]
n7[import httpx]
n8[from pydantic import HttpUrl]
n9[from services.aiva_common.schemas import FunctionT...]
n10[class PrivilegeLevel(...)]
n11[class VerticalTestResult(...)]
n12[class VerticalEscalationTester(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nVertical Escalation Tester for IDOR Detect...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[from enum import Enum]
n7[import httpx]
n8[from pydantic import HttpUrl]
n9[from services.aiva_common.schemas import FunctionT...]
n10[class PrivilegeLevel(...)]
n11[class VerticalTestResult(...)]
n12[class VerticalEscalationTester(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
584. function function idor aiva func idor worker Function init
flowchart TB
n1([開始])
n2([結束])
n3['Initialize IDOR worker with detectors.&&...]
n4[self.extractor = ResourceIdExtractor(...]
n5[self.http_client = httpx.AsyncClient(ti...]
n6[self.tester = CrossUserTester(self...]
n7[self.vertical_tester = VerticalEscalationTe...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Initialize IDOR worker with detectors.&&...]
n4[self.extractor = ResourceIdExtractor(...]
n5[self.http_client = httpx.AsyncClient(ti...]
n6[self.tester = CrossUserTester(self...]
n7[self.vertical_tester = VerticalEscalationTe...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
585. function function idor aiva func idor worker Function build finding
flowchart TB
n1([開始])
n2([結束])
n3['\n Build a vulnerability finding from...]
n4[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Build a vulnerability finding from...]
n4[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n2
586. function function idor aiva func idor worker Function build vertical finding
flowchart TB
n1([開始])
n2([結束])
n3['\n Build a BFLA vulnerability finding...]
n4[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Build a BFLA vulnerability finding...]
n4[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n2
587. function function idor aiva func idor worker Function extract auth
flowchart TB
n1([開始])
n2([結束])
n3['\n Extract authentication information...]
n4[auth: dict[str, str] = {}]
n5{if task.target.headers}
n6{if 'Authorization' in task.tar...}
n7[auth['Authorization'] = t...]
n8[]
n9{if 'Cookie' in task.target.hea...}
n10[auth['Cookie'] = task.tar...]
n11[]
n12[]
n13{if task.target.cookies}
n14[from urllib.parse import quote]
n15[cookie_str = '; '.join((f...]
n16[auth['Cookie'] = cookie_str]
n17[]
n18[return auth]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Extract authentication information...]
n4[auth: dict[str, str] = {}]
n5{if task.target.headers}
n6{if &#39;Authorization&#39; in task.tar...}
n7[auth[&#39;Authorization&#39;] = t...]
n8[]
n9{if &#39;Cookie&#39; in task.target.hea...}
n10[auth[&#39;Cookie&#39;] = task.tar...]
n11[]
n12[]
n13{if task.target.cookies}
n14[from urllib.parse import quote]
n15[cookie_str = &#39;; &#39;.join((f...]
n16[auth[&#39;Cookie&#39;] = cookie_str]
n17[]
n18[return auth]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
588. function function idor aiva func idor worker Function get test user auth
flowchart TB
n1([開始])
n2([結束])
n3['\n Get test user authentication crede...]
n4[_ = task]
n5[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Get test user authentication crede...]
n4[_ = task]
n5[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
589. function function idor aiva func idor worker Function infer required privilege
flowchart TB
n1([開始])
n2([結束])
n3['\n Infer required privilege level fro...]
n4[url_lower = url.lower()]
n5{if any((pattern in url_lower f...}
n6[return PrivilegeLevel.ADMIN]
n7[]
n8{if any((pattern in url_lower f...}
n9[return PrivilegeLevel.MODERATOR]
n10[]
n11{if any((pattern in url_lower f...}
n12[return PrivilegeLevel.SUPERADMIN]
n13[]
n14[return PrivilegeLevel.USER]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Infer required privilege level fro...]
n4[url_lower = url.lower()]
n5{if any((pattern in url_lower f...}
n6[return PrivilegeLevel.ADMIN]
n7[]
n8{if any((pattern in url_lower f...}
n9[return PrivilegeLevel.MODERATOR]
n10[]
n11{if any((pattern in url_lower f...}
n12[return PrivilegeLevel.SUPERADMIN]
n13[]
n14[return PrivilegeLevel.USER]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n2
590. function function idor aiva func idor worker Function validated http url
flowchart TB
n1([開始])
n2([結束])
n3['Validate and convert string to HttpUrl.&...]
n4[return _HTTP_URL_VALIDATOR.validate_p...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Validate and convert string to HttpUrl.&...]
n4[return _HTTP_URL_VALIDATOR.validate_p...]
n1 --> n3
n3 --> n4
n4 --> n2
591. function function idor aiva func idor worker Module
flowchart TB
n1([開始])
n2([結束])
n3['\nIDOR Detection Worker\n\nMain worker for d...]
n4[from __future__ import annotations]
n5[import json]
n6[import httpx]
n7[from pydantic import HttpUrl, TypeAdapter]
n8[from services.aiva_common.enums import Confidence,...]
n9[from services.aiva_common.mq import get_broker]
n10[from services.aiva_common.schemas import AivaMessa...]
n11[from services.aiva_common.utils import get_logger,...]
n12[from .cross_user_tester import CrossUserTester, Cr...]
n13[from .resource_id_extractor import ResourceIdExtra...]
n14[from .vertical_escalation_tester import PrivilegeL...]
n15[logger = get_logger(__name__)]
n16[_HTTP_URL_VALIDATOR = TypeAdapter(HttpUrl)]
n17[def _validated_http_url(...)]
n18[def run(...)]
n19[class IdorWorker(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nIDOR Detection Worker\n\nMain worker for d...]
n4[from __future__ import annotations]
n5[import json]
n6[import httpx]
n7[from pydantic import HttpUrl, TypeAdapter]
n8[from services.aiva_common.enums import Confidence,...]
n9[from services.aiva_common.mq import get_broker]
n10[from services.aiva_common.schemas import AivaMessa...]
n11[from services.aiva_common.utils import get_logger,...]
n12[from .cross_user_tester import CrossUserTester, Cr...]
n13[from .resource_id_extractor import ResourceIdExtra...]
n14[from .vertical_escalation_tester import PrivilegeL...]
n15[logger = get_logger(__name__)]
n16[_HTTP_URL_VALIDATOR = TypeAdapter(HttpUrl)]
n17[def _validated_http_url(...)]
n18[def run(...)]
n19[class IdorWorker(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
592. function function postex init Module
flowchart TB
n1([開始])
n2([結束])
n3['\nPostEx Module - 後滲透測試模組 (僅供授權測試使用)...]
n4[from .lateral_movement import LateralMovementTeste...]
n5[from .persistence_checker import PersistenceChecke...]
n6[from .privilege_escalator import PrivilegeEscalato...]
n7[from .schemas import PostExDetectionResult, PostEx...]
n8[__all__ = ['LateralMovementTes...]
n9[__version__ = '1.0.0']
n10[__warning__ = 'FOR AUTHORIZED SECU...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nPostEx Module - 後滲透測試模組 (僅供授權測試使用)...]
n4[from .lateral_movement import LateralMovementTeste...]
n5[from .persistence_checker import PersistenceChecke...]
n6[from .privilege_escalator import PrivilegeEscalato...]
n7[from .schemas import PostExDetectionResult, PostEx...]
n8[__all__ = [&#39;LateralMovementTes...]
n9[__version__ = &#39;1.0.0&#39;]
n10[__warning__ = &#39;FOR AUTHORIZED SECU...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
593. function function postex lateral movement Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化橫向移動測試器\n\n Args:\n ...]
n4[self.authorization_token = authorization_token]
n5[self.target_network = target_network]
n6[self.safe_mode = safe_mode]
n7[self.test_results: list[dict[str, Any]] =...]
n8{if not authorization_token}
n9[logger.warning('lateral_movement_no_auth&...]
n10[self.safe_mode = True]
n11[]
n12[logger.info('lateral_movement_initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化橫向移動測試器\n\n Args:\n ...]
n4[self.authorization_token = authorization_token]
n5[self.target_network = target_network]
n6[self.safe_mode = safe_mode]
n7[self.test_results: list[dict[str, Any]] =...]
n8{if not authorization_token}
n9[logger.warning(&#39;lateral_movement_no_auth&...]
n10[self.safe_mode = True]
n11[]
n12[logger.info(&#39;lateral_movement_initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
594. function function postex lateral movement Function log action
flowchart TB
n1([開始])
n2([結束])
n3['記錄操作']
n4[log_entry = {'timestamp': da...]
n5[logger.info('lateral_movement_action&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄操作&#39;]
n4[log_entry = {&#39;timestamp&#39;: da...]
n5[logger.info(&#39;lateral_movement_action&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
595. function function postex lateral movement Function enumerate services
flowchart TB
n1([開始])
n2([結束])
n3['\n 枚舉目標主機服務\n\n Args:\n ...]
n4[self._log_action('enumerate_services&...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['services'].extend...]
n9[result['mode'] = &...]
n10[result['error'] = &...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 枚舉目標主機服務\n\n Args:\n ...]
n4[self._log_action(&#39;enumerate_services&...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;services&#39;].extend...]
n9[result[&#39;mode&#39;] = &...]
n10[result[&#39;error&#39;] = &&#...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
596. function function postex lateral movement Function get results
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有測試結果']
n4[return self.test_results]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有測試結果&#39;]
n4[return self.test_results]
n1 --> n3
n3 --> n4
n4 --> n2
597. function function postex lateral movement Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例 - 僅在安全模式下運行']
n4[print('⚠️ Lateral Movement Tester - SAFE...]
n5[print('=' * 60)]
n6[tester = LateralMovementTeste...]
n7[assessment = tester.run_full_asse...]
n8[print(f"\n📊 Assessment ID: {assessment&...]
n9[print(f"🔒 Safe Mode: {assessment[&a...]
n10[print(f"🌐 Target Network: {assessment...]
n11[print(f"\n📋 Tests Run: {assessment[...]
n12[print(f"🔍 Findings: {assessment[&am...]
n13[print('\n✅ Safe mode demo completed&&...]
n14[print('⚠️ Remember: Never use this tool ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例 - 僅在安全模式下運行&#39;]
n4[print(&#39;⚠️ Lateral Movement Tester - SAFE...]
n5[print(&#39;=&#39; * 60)]
n6[tester = LateralMovementTeste...]
n7[assessment = tester.run_full_asse...]
n8[print(f&quot;\n📊 Assessment ID: {assessment&...]
n9[print(f&quot;🔒 Safe Mode: {assessment[&a...]
n10[print(f&quot;🌐 Target Network: {assessment&#...]
n11[print(f&quot;\n📋 Tests Run: {assessment[...]
n12[print(f&quot;🔍 Findings: {assessment[&am...]
n13[print(&#39;\n✅ Safe mode demo completed&&...]
n14[print(&#39;⚠️ Remember: Never use this tool ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
598. function function postex lateral movement Function run full assessment
flowchart TB
n1([開始])
n2([結束])
n3['\n 執行完整的橫向移動評估\n\n Returns:\n ...]
n4[logger.info('lateral_movement_assessment_...]
n5[assessment = {'assessment_id'...]
n6[assessment['tests'].appen...]
n7[assessment['tests'].appen...]
n8[assessment['tests'].appen...]
n9[assessment['tests'].appen...]
n10[assessment['tests'].appen...]
n11[total_findings = sum((len(test.get(&&...]
n12[assessment['summary'] = &...]
n13[logger.info('lateral_movement_assessment_...]
n14[return assessment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 執行完整的橫向移動評估\n\n Returns:\n ...]
n4[logger.info(&#39;lateral_movement_assessment_...]
n5[assessment = {&#39;assessment_id&#39...]
n6[assessment[&#39;tests&#39;].appen...]
n7[assessment[&#39;tests&#39;].appen...]
n8[assessment[&#39;tests&#39;].appen...]
n9[assessment[&#39;tests&#39;].appen...]
n10[assessment[&#39;tests&#39;].appen...]
n11[total_findings = sum((len(test.get(&&...]
n12[assessment[&#39;summary&#39;] = &...]
n13[logger.info(&#39;lateral_movement_assessment_...]
n14[return assessment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
599. function function postex lateral movement Function simulate pass the hash
flowchart TB
n1([開始])
n2([結束])
n3['\n 模擬 Pass-the-Hash 攻擊\n\n Ret...]
n4[self._log_action('simulate_pass_the_hash&...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['findings'].append...]
n9[result['mode'] = &...]
n10[result['error'] = &...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 模擬 Pass-the-Hash 攻擊\n\n Ret...]
n4[self._log_action(&#39;simulate_pass_the_hash&...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;findings&#39;].append...]
n9[result[&#39;mode&#39;] = &...]
n10[result[&#39;error&#39;] = &&#...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
600. function function postex lateral movement Function test credential reuse
flowchart TB
n1([開始])
n2([結束])
n3['\n 測試憑證重用\n\n Args:\n ...]
n4[self._log_action('test_credential_reuse&a...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['findings'].append...]
n9[result['mode'] = &...]
n10[result['error'] = &...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 測試憑證重用\n\n Args:\n ...]
n4[self._log_action(&#39;test_credential_reuse&a...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;findings&#39;].append...]
n9[result[&#39;mode&#39;] = &...]
n10[result[&#39;error&#39;] = &&#...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
601. function function postex lateral movement Function test remote access
flowchart TB
n1([開始])
n2([結束])
n3['\n 測試遠程訪問協議\n\n Args:\n ...]
n4[protocols = protocols or ['ssh...]
n5[self._log_action('test_remote_access&...]
n6[result = {'test_name': &...]
n7{if self.safe_mode}
n8[result['mode'] = &...]
n9{for protocol in protocols}
n10[result['findings'].append...]
n11[]
n12[result['mode'] = &...]
n13[result['error'] = &...]
n14[]
n15[self.test_results.append(result)]
n16[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n9
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 測試遠程訪問協議\n\n Args:\n ...]
n4[protocols = protocols or [&#39;ssh&#3...]
n5[self._log_action(&#39;test_remote_access&...]
n6[result = {&#39;test_name&#39;: &...]
n7{if self.safe_mode}
n8[result[&#39;mode&#39;] = &...]
n9{for protocol in protocols}
n10[result[&#39;findings&#39;].append...]
n11[]
n12[result[&#39;mode&#39;] = &...]
n13[result[&#39;error&#39;] = &&#...]
n14[]
n15[self.test_results.append(result)]
n16[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n9
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
602. function function postex lateral movement Module
flowchart TB
n1([開始])
n2([結束])
n3['\nLateral Movement Tester - 橫向移動測試器 (僅供授...]
n4[from datetime import datetime]
n5[import hashlib]
n6[import socket]
n7[from typing import Any]
n8[import structlog]
n9[logger = structlog.get_logger...]
n10[class LateralMovementTester(...)]
n11[def main(...)]
n12{if __name__ == '__main__'}
n13[main()]
n14[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nLateral Movement Tester - 橫向移動測試器 (僅供授...]
n4[from datetime import datetime]
n5[import hashlib]
n6[import socket]
n7[from typing import Any]
n8[import structlog]
n9[logger = structlog.get_logger...]
n10[class LateralMovementTester(...)]
n11[def main(...)]
n12{if __name__ == &#39;__main__&#39;}
n13[main()]
n14[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n2
603. function function postex persistence checker Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化持久化檢查器\n\n Args:\n ...]
n4[self.authorization_token = authorization_token]
n5[self.safe_mode = safe_mode]
n6[self.deep_scan = deep_scan]
n7[self.os_type = platform.system()]
n8[self.test_results: list[dict[str, Any]] =...]
n9{if not authorization_token}
n10[logger.warning('persistence_checker_no_au...]
n11[self.safe_mode = True]
n12[]
n13[logger.info('persistence_checker_initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化持久化檢查器\n\n Args:\n ...]
n4[self.authorization_token = authorization_token]
n5[self.safe_mode = safe_mode]
n6[self.deep_scan = deep_scan]
n7[self.os_type = platform.system()]
n8[self.test_results: list[dict[str, Any]] =...]
n9{if not authorization_token}
n10[logger.warning(&#39;persistence_checker_no_au...]
n11[self.safe_mode = True]
n12[]
n13[logger.info(&#39;persistence_checker_initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
604. function function postex persistence checker Function log action
flowchart TB
n1([開始])
n2([結束])
n3['記錄操作']
n4[log_entry = {'timestamp': da...]
n5[logger.info('persistence_check_action&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄操作&#39;]
n4[log_entry = {&#39;timestamp&#39;: da...]
n5[logger.info(&#39;persistence_check_action&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
605. function function postex persistence checker Function check cron jobs
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 Cron 任務 (Linux/macOS)\n...]
n4[self._log_action('check_cron_jobs&...]
n5[result = {'test_name': &...]
n6{if self.os_type == 'Windows'}
n7[result['note'] = &...]
n8[self.test_results.append(result)]
n9[return result]
n10[]
n11{if self.safe_mode}
n12[result['mode'] = &...]
n13[result['jobs'].append(...]
n14[result['jobs'].append(...]
n15[result['mode'] = &...]
n16[result['error'] = &...]
n17[]
n18[self.test_results.append(result)]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 Cron 任務 (Linux/macOS)\n...]
n4[self._log_action(&#39;check_cron_jobs&...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.os_type == &#39;Windows&#39;}
n7[result[&#39;note&#39;] = &...]
n8[self.test_results.append(result)]
n9[return result]
n10[]
n11{if self.safe_mode}
n12[result[&#39;mode&#39;] = &...]
n13[result[&#39;jobs&#39;].append(...]
n14[result[&#39;jobs&#39;].append(...]
n15[result[&#39;mode&#39;] = &...]
n16[result[&#39;error&#39;] = &&#...]
n17[]
n18[self.test_results.append(result)]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
606. function function postex persistence checker Function check registry persistence
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 Registry 持久化 (Windows)\...]
n4[self._log_action('check_registry_persiste...]
n5[result = {'test_name': &...]
n6{if self.os_type != 'Windows'}
n7[result['note'] = &...]
n8[self.test_results.append(result)]
n9[return result]
n10[]
n11{if self.safe_mode}
n12[result['mode'] = &...]
n13[common_locations = ['HKLM\\Software\\Mi...]
n14[result['entries'].extend&...]
n15[result['mode'] = &...]
n16[result['error'] = &...]
n17[]
n18[self.test_results.append(result)]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 Registry 持久化 (Windows)\...]
n4[self._log_action(&#39;check_registry_persiste...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.os_type != &#39;Windows&#39;}
n7[result[&#39;note&#39;] = &...]
n8[self.test_results.append(result)]
n9[return result]
n10[]
n11{if self.safe_mode}
n12[result[&#39;mode&#39;] = &...]
n13[common_locations = [&#39;HKLM\\Software\\Mi...]
n14[result[&#39;entries&#39;].extend&...]
n15[result[&#39;mode&#39;] = &...]
n16[result[&#39;error&#39;] = &&#...]
n17[]
n18[self.test_results.append(result)]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n10
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
607. function function postex persistence checker Function check scheduled tasks
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查計劃任務\n\n Returns:\n ...]
n4[self._log_action('check_scheduled_tasks&a...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8{if self.os_type == 'Windows'}
n9[result['tasks'].append...]
n10[result['tasks'].append...]
n11[]
n12[result['mode'] = &...]
n13[result['error'] = &...]
n14[]
n15[self.test_results.append(result)]
n16[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查計劃任務\n\n Returns:\n ...]
n4[self._log_action(&#39;check_scheduled_tasks&a...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8{if self.os_type == &#39;Windows&#39;}
n9[result[&#39;tasks&#39;].append...]
n10[result[&#39;tasks&#39;].append...]
n11[]
n12[result[&#39;mode&#39;] = &...]
n13[result[&#39;error&#39;] = &&#...]
n14[]
n15[self.test_results.append(result)]
n16[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
608. function function postex persistence checker Function check services
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查系統服務\n\n Returns:\n ...]
n4[self._log_action('check_services&#...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[try]
n9[process_count = len(list(psutil.proc...]
n10[result['services'].append...]
n11[]
n12[except Exception]
n13[result['services'].append...]
n14[result['mode'] = &...]
n15[result['error'] = &...]
n16[]
n17[self.test_results.append(result)]
n18[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n14
n7 --> n8
n8 --> n9
n8 --> n12
n9 --> n10
n10 --> n11
n11 --> n16
n12 --> n13
n13 --> n11
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查系統服務\n\n Returns:\n ...]
n4[self._log_action(&#39;check_services&#...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[try]
n9[process_count = len(list(psutil.proc...]
n10[result[&#39;services&#39;].append...]
n11[]
n12[except Exception]
n13[result[&#39;services&#39;].append...]
n14[result[&#39;mode&#39;] = &...]
n15[result[&#39;error&#39;] = &&#...]
n16[]
n17[self.test_results.append(result)]
n18[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n14
n7 --> n8
n8 --> n9
n8 --> n12
n9 --> n10
n10 --> n11
n11 --> n16
n12 --> n13
n13 --> n11
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
609. function function postex persistence checker Function check startup items
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查啟動項\n\n Returns:\n ...]
n4[self._log_action('check_startup_items&...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8{if self.os_type == 'Windows'}
n9[result['items'].extend...]
n10[result['items'].extend...]
n11[]
n12[result['mode'] = &...]
n13[result['error'] = &...]
n14[]
n15[self.test_results.append(result)]
n16[logger.info('startup_items_checked&...]
n17[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查啟動項\n\n Returns:\n ...]
n4[self._log_action(&#39;check_startup_items&...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8{if self.os_type == &#39;Windows&#39;}
n9[result[&#39;items&#39;].extend...]
n10[result[&#39;items&#39;].extend...]
n11[]
n12[result[&#39;mode&#39;] = &...]
n13[result[&#39;error&#39;] = &&#...]
n14[]
n15[self.test_results.append(result)]
n16[logger.info(&#39;startup_items_checked&&#...]
n17[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n12
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
610. function function postex persistence checker Function get results
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有測試結果']
n4[return self.test_results]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有測試結果&#39;]
n4[return self.test_results]
n1 --> n3
n3 --> n4
n4 --> n2
611. function function postex persistence checker Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例 - 僅在安全模式下運行']
n4[print('⚠️ Persistence Checker - SAFE MOD...]
n5[print('=' * 60)]
n6[checker = PersistenceChecker(s...]
n7[assessment = checker.run_full_ass...]
n8[print(f"\n📊 Assessment ID: {assessment&...]
n9[print(f"🔒 Safe Mode: {assessment[&a...]
n10[print(f"💻 OS: {assessment[&#...]
n11[print(f"\n📋 Tests Run: {assessment[...]
n12[print(f"🔍 Findings: {assessment[&am...]
n13[print('\n✅ Safe mode demo completed&&...]
n14[print('⚠️ Remember: Never use this tool ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例 - 僅在安全模式下運行&#39;]
n4[print(&#39;⚠️ Persistence Checker - SAFE MOD...]
n5[print(&#39;=&#39; * 60)]
n6[checker = PersistenceChecker(s...]
n7[assessment = checker.run_full_ass...]
n8[print(f&quot;\n📊 Assessment ID: {assessment&...]
n9[print(f&quot;🔒 Safe Mode: {assessment[&a...]
n10[print(f&quot;💻 OS: {assessment[&#...]
n11[print(f&quot;\n📋 Tests Run: {assessment[...]
n12[print(f&quot;🔍 Findings: {assessment[&am...]
n13[print(&#39;\n✅ Safe mode demo completed&&...]
n14[print(&#39;⚠️ Remember: Never use this tool ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
612. function function postex persistence checker Function run full assessment
flowchart TB
n1([開始])
n2([結束])
n3['\n 執行完整的持久化檢查\n\n Returns:\n ...]
n4[logger.info('persistence_assessment_start...]
n5[assessment = {'assessment_id'...]
n6[assessment['tests'].appen...]
n7[assessment['tests'].appen...]
n8[assessment['tests'].appen...]
n9{if self.os_type == 'Windows'}
n10[assessment['tests'].appen...]
n11[assessment['tests'].appen...]
n12[]
n13[total_findings = sum((len(test.get(&&...]
n14[assessment['summary'] = &...]
n15[logger.info('persistence_assessment_compl...]
n16[return assessment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 執行完整的持久化檢查\n\n Returns:\n ...]
n4[logger.info(&#39;persistence_assessment_start...]
n5[assessment = {&#39;assessment_id&#39...]
n6[assessment[&#39;tests&#39;].appen...]
n7[assessment[&#39;tests&#39;].appen...]
n8[assessment[&#39;tests&#39;].appen...]
n9{if self.os_type == &#39;Windows&#39;}
n10[assessment[&#39;tests&#39;].appen...]
n11[assessment[&#39;tests&#39;].appen...]
n12[]
n13[total_findings = sum((len(test.get(&&...]
n14[assessment[&#39;summary&#39;] = &...]
n15[logger.info(&#39;persistence_assessment_compl...]
n16[return assessment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
613. function function postex persistence checker Module
flowchart TB
n1([開始])
n2([結束])
n3['\nPersistence Checker - 持久化檢查器 (僅供授權測試使用...]
n4[from datetime import datetime]
n5[import hashlib]
n6[import platform]
n7[from typing import Any]
n8[import psutil]
n9[import structlog]
n10[logger = structlog.get_logger...]
n11[class PersistenceChecker(...)]
n12[def main(...)]
n13{if __name__ == '__main__'}
n14[main()]
n15[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nPersistence Checker - 持久化檢查器 (僅供授權測試使用...]
n4[from datetime import datetime]
n5[import hashlib]
n6[import platform]
n7[from typing import Any]
n8[import psutil]
n9[import structlog]
n10[logger = structlog.get_logger...]
n11[class PersistenceChecker(...)]
n12[def main(...)]
n13{if __name__ == &#39;__main__&#39;}
n14[main()]
n15[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n2
614. function function postex privilege escalator Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化權限提升測試器\n\n Args:\n ...]
n4[self.authorization_token = authorization_token]
n5[self.log_all_actions = log_all_actions]
n6[self.safe_mode = safe_mode]
n7[self.test_results: list[dict[str, Any]] =...]
n8{if not authorization_token}
n9[logger.warning('privilege_escalator_no_au...]
n10[self.safe_mode = True]
n11[]
n12[logger.info('privilege_escalator_initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化權限提升測試器\n\n Args:\n ...]
n4[self.authorization_token = authorization_token]
n5[self.log_all_actions = log_all_actions]
n6[self.safe_mode = safe_mode]
n7[self.test_results: list[dict[str, Any]] =...]
n8{if not authorization_token}
n9[logger.warning(&#39;privilege_escalator_no_au...]
n10[self.safe_mode = True]
n11[]
n12[logger.info(&#39;privilege_escalator_initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
615. function function postex privilege escalator Function check authorization
flowchart TB
n1([開始])
n2([結束])
n3['檢查授權']
n4{if not self.authorization_token}
n5[return False]
n6[]
n7[return len(self.authorization_token) ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查授權&#39;]
n4{if not self.authorization_token}
n5[return False]
n6[]
n7[return len(self.authorization_token) ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
616. function function postex privilege escalator Function log action
flowchart TB
n1([開始])
n2([結束])
n3['記錄操作']
n4{if self.log_all_actions}
n5[log_entry = {'timestamp': da...]
n6[logger.info('privilege_escalation_action&...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄操作&#39;]
n4{if self.log_all_actions}
n5[log_entry = {&#39;timestamp&#39;: da...]
n6[logger.info(&#39;privilege_escalation_action&...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
617. function function postex privilege escalator Function check kernel exploits
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查已知內核漏洞\n\n Returns:\n ...]
n4[self._log_action('check_kernel_exploits&a...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['findings'].append...]
n9[]
n10[self.test_results.append(result)]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查已知內核漏洞\n\n Returns:\n ...]
n4[self._log_action(&#39;check_kernel_exploits&a...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;findings&#39;].append...]
n9[]
n10[self.test_results.append(result)]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
618. function function postex privilege escalator Function check sudo misconfiguration
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 Sudo 配置錯誤\n\n Returns:\n...]
n4[self._log_action('check_sudo_misconfigura...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['findings'].append...]
n9[result['mode'] = &...]
n10[result['error'] = &...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 Sudo 配置錯誤\n\n Returns:\n...]
n4[self._log_action(&#39;check_sudo_misconfigura...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;findings&#39;].append...]
n9[result[&#39;mode&#39;] = &...]
n10[result[&#39;error&#39;] = &&#...]
n11[]
n12[self.test_results.append(result)]
n13[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
619. function function postex privilege escalator Function check suid binaries
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 SUID/SGID 二進制文件\n\n Retu...]
n4[self._log_action('check_suid_binaries&...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['findings'].append...]
n9[result['mode'] = &...]
n10[result['error'] = &...]
n11[]
n12[self.test_results.append(result)]
n13[logger.info('suid_check_completed&...]
n14[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 SUID/SGID 二進制文件\n\n Retu...]
n4[self._log_action(&#39;check_suid_binaries&...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;findings&#39;].append...]
n9[result[&#39;mode&#39;] = &...]
n10[result[&#39;error&#39;] = &&#...]
n11[]
n12[self.test_results.append(result)]
n13[logger.info(&#39;suid_check_completed&...]
n14[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
620. function function postex privilege escalator Function check writable services
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查可寫服務配置\n\n Returns:\n ...]
n4[self._log_action('check_writable_services...]
n5[result = {'test_name': &...]
n6{if self.safe_mode}
n7[result['mode'] = &...]
n8[result['findings'].append...]
n9[]
n10[self.test_results.append(result)]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查可寫服務配置\n\n Returns:\n ...]
n4[self._log_action(&#39;check_writable_services...]
n5[result = {&#39;test_name&#39;: &...]
n6{if self.safe_mode}
n7[result[&#39;mode&#39;] = &...]
n8[result[&#39;findings&#39;].append...]
n9[]
n10[self.test_results.append(result)]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
621. function function postex privilege escalator Function clear results
flowchart TB
n1([開始])
n2([結束])
n3['清除測試結果']
n4[self.test_results.clear()]
n5[logger.info('test_results_cleared&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清除測試結果&#39;]
n4[self.test_results.clear()]
n5[logger.info(&#39;test_results_cleared&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
622. function function postex privilege escalator Function get results
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有測試結果']
n4[return self.test_results]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有測試結果&#39;]
n4[return self.test_results]
n1 --> n3
n3 --> n4
n4 --> n2
623. function function postex privilege escalator Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例 - 僅在安全模式下運行']
n4[print('⚠️ Privilege Escalation Tester - ...]
n5[print('=' * 60)]
n6[escalator = PrivilegeEscalator(s...]
n7[assessment = escalator.run_full_a...]
n8[print(f"\n📊 Assessment ID: {assessment&...]
n9[print(f"🔒 Safe Mode: {assessment[&a...]
n10[print(f"💻 OS: {assessment[&#...]
n11[print(f"\n📋 Tests Run: {assessment[...]
n12[print(f"🔍 Findings: {assessment[&am...]
n13[print('\n✅ Safe mode demo completed&&...]
n14[print('⚠️ Remember: Never use this tool ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例 - 僅在安全模式下運行&#39;]
n4[print(&#39;⚠️ Privilege Escalation Tester - ...]
n5[print(&#39;=&#39; * 60)]
n6[escalator = PrivilegeEscalator(s...]
n7[assessment = escalator.run_full_a...]
n8[print(f&quot;\n📊 Assessment ID: {assessment&...]
n9[print(f&quot;🔒 Safe Mode: {assessment[&a...]
n10[print(f&quot;💻 OS: {assessment[&#...]
n11[print(f&quot;\n📋 Tests Run: {assessment[...]
n12[print(f&quot;🔍 Findings: {assessment[&am...]
n13[print(&#39;\n✅ Safe mode demo completed&&...]
n14[print(&#39;⚠️ Remember: Never use this tool ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
624. function function postex privilege escalator Function run full assessment
flowchart TB
n1([開始])
n2([結束])
n3['\n 執行完整的權限提升評估\n\n Returns:\n ...]
n4[logger.info('privilege_escalation_assessm...]
n5[assessment = {'assessment_id'...]
n6[assessment['tests'].appen...]
n7[assessment['tests'].appen...]
n8[assessment['tests'].appen...]
n9[assessment['tests'].appen...]
n10[total_findings = sum((len(test.get(&&...]
n11[assessment['summary'] = &...]
n12[logger.info('privilege_escalation_assessm...]
n13[return assessment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 執行完整的權限提升評估\n\n Returns:\n ...]
n4[logger.info(&#39;privilege_escalation_assessm...]
n5[assessment = {&#39;assessment_id&#39...]
n6[assessment[&#39;tests&#39;].appen...]
n7[assessment[&#39;tests&#39;].appen...]
n8[assessment[&#39;tests&#39;].appen...]
n9[assessment[&#39;tests&#39;].appen...]
n10[total_findings = sum((len(test.get(&&...]
n11[assessment[&#39;summary&#39;] = &...]
n12[logger.info(&#39;privilege_escalation_assessm...]
n13[return assessment]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
625. function function postex privilege escalator Module
flowchart TB
n1([開始])
n2([結束])
n3['\nPrivilege Escalator - 權限提升測試器 (僅供授權測試使...]
n4[from datetime import datetime]
n5[import hashlib]
n6[import platform]
n7[from typing import Any]
n8[import structlog]
n9[logger = structlog.get_logger...]
n10[class AuthorizationError(...)]
n11[class PrivilegeEscalator(...)]
n12[def main(...)]
n13{if __name__ == '__main__'}
n14[main()]
n15[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nPrivilege Escalator - 權限提升測試器 (僅供授權測試使...]
n4[from datetime import datetime]
n5[import hashlib]
n6[import platform]
n7[from typing import Any]
n8[import structlog]
n9[logger = structlog.get_logger...]
n10[class AuthorizationError(...)]
n11[class PrivilegeEscalator(...)]
n12[def main(...)]
n13{if __name__ == &#39;__main__&#39;}
n14[main()]
n15[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n2
626. function function postex schemas Function calculate risk score
flowchart TB
n1([開始])
n2([結束])
n3['計算風險評分 (0.0-1.0)']
n4[score = 0.0]
n5{if self.execution_successful}
n6[score += 0.2]
n7[]
n8{if self.privileges_escalated}
n9[score += 0.25]
n10[]
n11{if self.lateral_movement_achieved}
n12[score += 0.2]
n13[]
n14{if self.persistence_established}
n15[score += 0.15]
n16[]
n17{if self.data_exfiltrated}
n18[score += 0.3]
n19[]
n20{if self.detection_evaded}
n21[score += 0.1]
n22[]
n23[severity_multiplier = {ThreatLevel.LOW: 0....]
n24[return min(score * severity_multiplie...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算風險評分 (0.0-1.0)&#39;]
n4[score = 0.0]
n5{if self.execution_successful}
n6[score += 0.2]
n7[]
n8{if self.privileges_escalated}
n9[score += 0.25]
n10[]
n11{if self.lateral_movement_achieved}
n12[score += 0.2]
n13[]
n14{if self.persistence_established}
n15[score += 0.15]
n16[]
n17{if self.data_exfiltrated}
n18[score += 0.3]
n19[]
n20{if self.detection_evaded}
n21[score += 0.1]
n22[]
n23[severity_multiplier = {ThreatLevel.LOW: 0....]
n24[return min(score * severity_multiplie...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
627. function function postex schemas Function get mitre techniques
flowchart TB
n1([開始])
n2([結束])
n3['獲取涉及的 MITRE ATT&CK 技術']
n4[techniques = [self.test_vector.te...]
n5{if self.privileges_escalated}
n6[techniques.extend(['T1055'...]
n7[]
n8{if self.lateral_movement_achieved}
n9[techniques.extend(['T1021'...]
n10[]
n11{if self.persistence_established}
n12[techniques.extend(['T1053'...]
n13[]
n14{if self.data_exfiltrated}
n15[techniques.extend(['T1041'...]
n16[]
n17[return list(set(techniques))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取涉及的 MITRE ATT&CK 技術&#39;]
n4[techniques = [self.test_vector.te...]
n5{if self.privileges_escalated}
n6[techniques.extend([&#39;T1055&#39...]
n7[]
n8{if self.lateral_movement_achieved}
n9[techniques.extend([&#39;T1021&#39...]
n10[]
n11{if self.persistence_established}
n12[techniques.extend([&#39;T1053&#39...]
n13[]
n14{if self.data_exfiltrated}
n15[techniques.extend([&#39;T1041&#39...]
n16[]
n17[return list(set(techniques))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
628. function function postex schemas Function get stealth score
flowchart TB
n1([開始])
n2([結束])
n3['獲取隱蔽性評分 (0.0-1.0, 1.0 = 完全隱蔽)&...]
n4{if self.tests_executed == 0}
n5[return 0.0]
n6[]
n7[evasion_rate = self.detection_evasi...]
n8[artifacts_per_test = self.artifacts_left ...]
n9[stealth_score = evasion_rate * (1.0 ...]
n10[return stealth_score]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取隱蔽性評分 (0.0-1.0, 1.0 = 完全隱蔽)&&#...]
n4{if self.tests_executed == 0}
n5[return 0.0]
n6[]
n7[evasion_rate = self.detection_evasi...]
n8[artifacts_per_test = self.artifacts_left ...]
n9[stealth_score = evasion_rate * (1.0 ...]
n10[return stealth_score]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
629. function function postex schemas Function get success rate
flowchart TB
n1([開始])
n2([結束])
n3['獲取成功率']
n4{if self.tests_executed == 0}
n5[return 0.0]
n6[]
n7[return self.successful_executions / s...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取成功率&#39;]
n4{if self.tests_executed == 0}
n5[return 0.0]
n6[]
n7[return self.successful_executions / s...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
630. function function postex schemas Function record test result
flowchart TB
n1([開始])
n2([結束])
n3['記錄測試結果']
n4[self.tests_executed += 1]
n5{if result.execution_successful}
n6[self.successful_executions += 1]
n7[]
n8{if result.privileges_escalated}
n9[self.privilege_escalations += 1]
n10[]
n11{if result.lateral_movement_ach...}
n12[self.lateral_movements += 1]
n13[]
n14{if result.persistence_established}
n15[self.persistence_attempts += 1]
n16[]
n17{if result.data_exfiltrated}
n18[self.data_exfiltrations += 1]
n19[]
n20{if result.detection_evaded}
n21[self.detection_evasions += 1]
n22[]
n23[technique_id = result.test_vector.t...]
n24[self.techniques_used[technique_id] = self.techniq...]
n25[tactic = result.test_vector.t...]
n26{if tactic not in self.tactics_...}
n27[self.tactics_covered.append(tactic)]
n28[]
n29[self.artifacts_left += len(result.artifacts_create...]
n30{if self.tests_executed == 1}
n31[self.average_execution_time_ms = result.execution_tim...]
n32[self.average_execution_time_ms = (self.average_execut...]
n33[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n32
n31 --> n33
n32 --> n33
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄測試結果&#39;]
n4[self.tests_executed += 1]
n5{if result.execution_successful}
n6[self.successful_executions += 1]
n7[]
n8{if result.privileges_escalated}
n9[self.privilege_escalations += 1]
n10[]
n11{if result.lateral_movement_ach...}
n12[self.lateral_movements += 1]
n13[]
n14{if result.persistence_established}
n15[self.persistence_attempts += 1]
n16[]
n17{if result.data_exfiltrated}
n18[self.data_exfiltrations += 1]
n19[]
n20{if result.detection_evaded}
n21[self.detection_evasions += 1]
n22[]
n23[technique_id = result.test_vector.t...]
n24[self.techniques_used[technique_id] = self.techniq...]
n25[tactic = result.test_vector.t...]
n26{if tactic not in self.tactics_...}
n27[self.tactics_covered.append(tactic)]
n28[]
n29[self.artifacts_left += len(result.artifacts_create...]
n30{if self.tests_executed == 1}
n31[self.average_execution_time_ms = result.execution_tim...]
n32[self.average_execution_time_ms = (self.average_execut...]
n33[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n32
n31 --> n33
n32 --> n33
n33 --> n2
631. function function postex schemas Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式']
n4[details = super().to_details(f...]
n5[details.update({'tests_executed&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式&#39;]
n4[details = super().to_details(f...]
n5[details.update({&#39;tests_executed&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
632. function function postex schemas Function validate os type
flowchart TB
n1([開始])
n2([結束])
n3['驗證作業系統類型']
n4[allowed = {'windows', &&...]
n5{if v.lower() not in allowed}
n6[raise ValueError(f'Invalid OS type: {...]
n7[]
n8[return v.lower()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證作業系統類型&#39;]
n4[allowed = {&#39;windows&#39;, &&...]
n5{if v.lower() not in allowed}
n6[raise ValueError(f&#39;Invalid OS type: {...]
n7[]
n8[return v.lower()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
633. function function postex schemas Function validate tactic
flowchart TB
n1([開始])
n2([結束])
n3['驗證 MITRE ATT&CK 戰術名稱']
n4[allowed_tactics = {'Initial Access&&...]
n5{if v not in allowed_tactics}
n6[raise ValueError(f'Invalid MITRE ATT&...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 MITRE ATT&CK 戰術名稱&#39;]
n4[allowed_tactics = {&#39;Initial Access&&...]
n5{if v not in allowed_tactics}
n6[raise ValueError(f&#39;Invalid MITRE ATT&...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
634. function function postex schemas Function validate technique id
flowchart TB
n1([開始])
n2([結束])
n3['驗證 MITRE ATT&CK 技術 ID 格式']
n4[import re]
n5{if not re.match('^T\\d{4}(\...}
n6[raise ValueError(f'Invalid MITRE ATT&...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 MITRE ATT&CK 技術 ID 格式&#39;]
n4[import re]
n5{if not re.match(&#39;^T\\d{4}(\...}
n6[raise ValueError(f&#39;Invalid MITRE ATT&...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
635. function function postex schemas Function validate test type
flowchart TB
n1([開始])
n2([結束])
n3['驗證測試類型']
n4[return v]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證測試類型&#39;]
n4[return v]
n1 --> n3
n3 --> n4
n4 --> n2
636. function function postex schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nPostEx (Post-Exploitation) 模組專用數據合...]
n4[from __future__ import annotations]
n5[from datetime import UTC, datetime]
n6[from typing import Any]
n7[from pydantic import BaseModel, Field, field_valid...]
n8[from services.aiva_common.enums import PostExTestT...]
n9[from services.aiva_common.schemas import FindingPa...]
n10[class PostExTestVector(...)]
n11[class PostExDetectionResult(...)]
n12[class SystemFingerprint(...)]
n13[class PostExTelemetry(...)]
n14[class TaskExecutionResult(...)]
n15[__all__ = ['PostExTestVector'...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nPostEx (Post-Exploitation) 模組專用數據合...]
n4[from __future__ import annotations]
n5[from datetime import UTC, datetime]
n6[from typing import Any]
n7[from pydantic import BaseModel, Field, field_valid...]
n8[from services.aiva_common.enums import PostExTestT...]
n9[from services.aiva_common.schemas import FindingPa...]
n10[class PostExTestVector(...)]
n11[class PostExDetectionResult(...)]
n12[class SystemFingerprint(...)]
n13[class PostExTelemetry(...)]
n14[class TaskExecutionResult(...)]
n15[__all__ = [&#39;PostExTestVector&#39;...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
637. function function sqli init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
638. function function sqli aiva func sqli init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
639. function function sqli aiva func sqli backend db fingerprinter Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._db_patterns = {'MySQL'...]
n4[self._version_patterns = {'MySQL&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._db_patterns = {&#39;MySQL&#39;...]
n4[self._version_patterns = {&#39;MySQL&...]
n1 --> n3
n3 --> n4
n4 --> n2
640. function function sqli aiva func sqli backend db fingerprinter Function contains sql keywords
flowchart TB
n1([開始])
n2([結束])
n3['檢測文本中的SQL關鍵字']
n4[sql_keywords = ['SELECT', &am...]
n5[found_keywords = []]
n6[text_upper = text.upper()]
n7{for keyword in sql_keywords}
n8{if keyword in text_upper}
n9[found_keywords.append(keyword)]
n10[]
n11[]
n12[return found_keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測文本中的SQL關鍵字&#39;]
n4[sql_keywords = [&#39;SELECT&#39;, &am...]
n5[found_keywords = []]
n6[text_upper = text.upper()]
n7{for keyword in sql_keywords}
n8{if keyword in text_upper}
n9[found_keywords.append(keyword)]
n10[]
n11[]
n12[return found_keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
641. function function sqli aiva func sqli backend db fingerprinter Function extract error signatures
flowchart TB
n1([開始])
n2([結束])
n3['提取錯誤簽名']
n4[error_signatures = []]
n5[error_patterns = ['syntax error&#...]
n6{for pattern in error_patterns}
n7[matches = re.findall(pattern, ...]
n8[error_signatures.extend(matches)]
n9[]
n10[return list(set(error_signatures))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n6
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取錯誤簽名&#39;]
n4[error_signatures = []]
n5[error_patterns = [&#39;syntax error&#...]
n6{for pattern in error_patterns}
n7[matches = re.findall(pattern, ...]
n8[error_signatures.extend(matches)]
n9[]
n10[return list(set(error_signatures))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n6
n9 --> n10
n10 --> n2
642. function function sqli aiva func sqli backend db fingerprinter Function extract version
flowchart TB
n1([開始])
n2([結束])
n3['提取資料庫版本資訊']
n4[version_patterns = self._version_patter...]
n5{for pattern in version_patterns}
n6[match = re.search(pattern, t...]
n7{if match}
n8[version = match.group(1)]
n9[logger.info(f'Version extracted for {...]
n10[return version]
n11[]
n12[]
n13[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取資料庫版本資訊&#39;]
n4[version_patterns = self._version_patter...]
n5{for pattern in version_patterns}
n6[match = re.search(pattern, t...]
n7{if match}
n8[version = match.group(1)]
n9[logger.info(f&#39;Version extracted for {...]
n10[return version]
n11[]
n12[]
n13[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
643. function function sqli aiva func sqli backend db fingerprinter Function add custom pattern
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加自定義資料庫識別模式\n\n Args:\n ...]
n4{if db_name not in self._db_pat...}
n5[self._db_patterns[db_name] = []]
n6[]
n7[self._db_patterns[db_name].append(pattern)]
n8[logger.info(f'Added custom pattern for ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加自定義資料庫識別模式\n\n Args:\n ...]
n4{if db_name not in self._db_pat...}
n5[self._db_patterns[db_name] = []]
n6[]
n7[self._db_patterns[db_name].append(pattern)]
n8[logger.info(f&#39;Added custom pattern for &#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
644. function function sqli aiva func sqli backend db fingerprinter Function add custom version pattern
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加自定義版本提取模式\n\n Args:\n ...]
n4{if db_name not in self._versio...}
n5[self._version_patterns[db_name] = []]
n6[]
n7[self._version_patterns[db_name].append(patter...]
n8[logger.info(f'Added custom version patter...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加自定義版本提取模式\n\n Args:\n ...]
n4{if db_name not in self._versio...}
n5[self._version_patterns[db_name] = []]
n6[]
n7[self._version_patterns[db_name].append(patter...]
n8[logger.info(f&#39;Added custom version patter...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
645. function function sqli aiva func sqli backend db fingerprinter Function analyze response characteristics
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析回應特徵以輔助指紋識別\n\n Args:\n ...]
n4[characteristics = {'status_code&#...]
n5[return characteristics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析回應特徵以輔助指紋識別\n\n Args:\n ...]
n4[characteristics = {&#39;status_code&#...]
n5[return characteristics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
646. function function sqli aiva func sqli backend db fingerprinter Function fingerprint
flowchart TB
n1([開始])
n2([結束])
n3['\n 從HTTP回應中識別資料庫類型和版本\n\n Args...]
n4{if response is None}
n5[return None]
n6[]
n7[text_sources = [response.text or '&...]
n8[combined_text = ' '.join(text...]
n9{for (db_name, patterns) in self._db_patterns...}
n10{for pattern in patterns}
n11{if re.search(pattern, combined...}
n12[logger.info(f'Database fingerprint detect...]
n13[version = self._extract_versio...]
n14[return (db_name, version)]
n15[]
n16[]
n17[]
n18[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n17
n10 -->|Yes| n11
n10 -->|No| n16
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n9
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 從HTTP回應中識別資料庫類型和版本\n\n Args...]
n4{if response is None}
n5[return None]
n6[]
n7[text_sources = [response.text or &#39;&&#...]
n8[combined_text = &#39; &#39;.join(text...]
n9{for (db_name, patterns) in self._db_patterns...}
n10{for pattern in patterns}
n11{if re.search(pattern, combined...}
n12[logger.info(f&#39;Database fingerprint detect...]
n13[version = self._extract_versio...]
n14[return (db_name, version)]
n15[]
n16[]
n17[]
n18[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n17
n10 -->|Yes| n11
n10 -->|No| n16
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n9
n17 --> n18
n18 --> n2
647. function function sqli aiva func sqli backend db fingerprinter Function get supported databases
flowchart TB
n1([開始])
n2([結束])
n3['獲取支援的資料庫類型列表']
n4[return list(self._db_patterns.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取支援的資料庫類型列表&#39;]
n4[return list(self._db_patterns.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
648. function function sqli aiva func sqli backend db fingerprinter Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import re]
n5[from typing import Any]
n6[import httpx]
n7[from services.aiva_common.utils import get_logger]
n8[logger = get_logger(__name__)]
n9[class BackendDbFingerprinter(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import re]
n5[from typing import Any]
n6[import httpx]
n7[from services.aiva_common.utils import get_logger]
n8[logger = get_logger(__name__)]
n9[class BackendDbFingerprinter(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
649. function function sqli aiva func sqli config Function create aggressive config
flowchart TB
n1([開始])
n2([結束])
n3['創建積極的檢測配置(用於專業測試)']
n4[return cls(engines={'error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建積極的檢測配置(用於專業測試)&#39;]
n4[return cls(engines={&#39;error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
650. function function sqli aiva func sqli config Function create safe config
flowchart TB
n1([開始])
n2([結束])
n3['創建安全的預設配置(用於生產環境)']
n4[return cls(engines={'error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建安全的預設配置(用於生產環境)&#39;]
n4[return cls(engines={&#39;error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
651. function function sqli aiva func sqli config Function get enabled engines
flowchart TB
n1([開始])
n2([結束])
n3['取得所有啟用的引擎列表']
n4[return [engine for engine, enabled in...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取得所有啟用的引擎列表&#39;]
n4[return [engine for engine, enabled in...]
n1 --> n3
n3 --> n4
n4 --> n2
652. function function sqli aiva func sqli config Function is engine enabled
flowchart TB
n1([開始])
n2([結束])
n3['檢查指定引擎是否啟用']
n4[return self.engines.get(engine_name, ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查指定引擎是否啟用&#39;]
n4[return self.engines.get(engine_name, ...]
n1 --> n3
n3 --> n4
n4 --> n2
653. function function sqli aiva func sqli config Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典格式']
n4[return {'engines': self.engi...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典格式&#39;]
n4[return {&#39;engines&#39;: self.engi...]
n1 --> n3
n3 --> n4
n4 --> n2
654. function function sqli aiva func sqli config Function validate
flowchart TB
n1([開始])
n2([結束])
n3['配置驗證']
n4{if self.timeout_seconds <= 0}
n5[raise ValueError('timeout_seconds must be...]
n6[]
n7{if self.max_retries < 0}
n8[raise ValueError('max_retries must be non...]
n9[]
n10{if self.concurrent_limit <= 0}
n11[raise ValueError('concurrent_limit must b...]
n12[]
n13{if self.time_delay_threshold <= 0}
n14[raise ValueError('time_delay_threshold mu...]
n15[]
n16{if not 0 <= self.boolean_diff_...}
n17[raise ValueError('boolean_diff_threshold ...]
n18[]
n19{if not 0 <= self.min_confidenc...}
n20[raise ValueError('min_confidence_score mu...]
n21[]
n22{if self.max_payload_length <= 0}
n23[raise ValueError('max_payload_length must...]
n24[]
n25[valid_engines = {'error', &a...]
n26{for engine in self.engines}
n27{if engine not in valid_engines}
n28[raise ValueError(f'Unknown engine: {...]
n29[]
n30[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n26
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;配置驗證&#39;]
n4{if self.timeout_seconds &lt;= 0}
n5[raise ValueError(&#39;timeout_seconds must be...]
n6[]
n7{if self.max_retries &lt; 0}
n8[raise ValueError(&#39;max_retries must be non...]
n9[]
n10{if self.concurrent_limit &lt;= 0}
n11[raise ValueError(&#39;concurrent_limit must b...]
n12[]
n13{if self.time_delay_threshold &lt;= 0}
n14[raise ValueError(&#39;time_delay_threshold mu...]
n15[]
n16{if not 0 &lt;= self.boolean_diff_...}
n17[raise ValueError(&#39;boolean_diff_threshold ...]
n18[]
n19{if not 0 &lt;= self.min_confidenc...}
n20[raise ValueError(&#39;min_confidence_score mu...]
n21[]
n22{if self.max_payload_length &lt;= 0}
n23[raise ValueError(&#39;max_payload_length must...]
n24[]
n25[valid_engines = {&#39;error&#39;, &a...]
n26{for engine in self.engines}
n27{if engine not in valid_engines}
n28[raise ValueError(f&#39;Unknown engine: {...]
n29[]
n30[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n26
n30 --> n2
655. function function sqli aiva func sqli config Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 檢測配置管理\n統一的配置類別和驗證邏輯\n']
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[class SqliConfig(...)]
n8[SqliEngineConfig = SqliConfig]
n9[SqliDetectionConfig = SqliConfig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 檢測配置管理\n統一的配置類別和驗證邏輯\n&#39;]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[class SqliConfig(...)]
n8[SqliEngineConfig = SqliConfig]
n9[SqliDetectionConfig = SqliConfig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
656. function function sqli aiva func sqli detection models Function str
flowchart TB
n1([開始])
n2([結束])
n3[return f'[{self.engine_name} ...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return f&#39;[{self.engine_name}	...]
n1 --> n3
n3 --> n2
657. function function sqli aiva func sqli detection models Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 檢測結果模型\n統一的檢測結果和錯誤模型,與實際引擎使用保持一致\n&am...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FindingEv...]
n7[class DetectionResult(...)]
n8[class DetectionError(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 檢測結果模型\n統一的檢測結果和錯誤模型,與實際引擎使用保持一致\n&am...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FindingEv...]
n7[class DetectionResult(...)]
n8[class DetectionError(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
658. function function sqli aiva func sqli engines init Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQL注入檢測引擎模塊\n']
n4[from .boolean_detection_engine import BooleanDetec...]
n5[from .error_detection_engine import ErrorDetection...]
n6[from .oob_detection_engine import OOBDetectionEngi...]
n7[from .time_detection_engine import TimeDetectionEn...]
n8[from .union_detection_engine import UnionDetection...]
n9[__all__ = ['ErrorDetectionEngi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQL注入檢測引擎模塊\n&#39;]
n4[from .boolean_detection_engine import BooleanDetec...]
n5[from .error_detection_engine import ErrorDetection...]
n6[from .oob_detection_engine import OOBDetectionEngi...]
n7[from .time_detection_engine import TimeDetectionEn...]
n8[from .union_detection_engine import UnionDetection...]
n9[__all__ = [&#39;ErrorDetectionEngi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
659. function function sqli aiva func sqli engines boolean detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.boolean_payloads = [("'...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.boolean_payloads = [(&quot;&#39;...]
n1 --> n3
n3 --> n2
660. function function sqli aiva func sqli engines boolean detection engine Function analyze boolean responses
flowchart TB
n1([開始])
n2([結束])
n3['分析布林回應以檢測SQL注入']
n4{if true_response.status_code !...}
n5[return True]
n6[]
n7[true_len = len(true_response.te...]
n8[false_len = len(false_response.t...]
n9[baseline_len = len(baseline.text or...]
n10{if abs(true_len - false_len) > 50}
n11[return True]
n12[]
n13{if baseline_len > 0}
n14[true_diff = abs(true_len - basel...]
n15[false_diff = abs(false_len - base...]
n16{if abs(true_diff - false_diff)...}
n17[return True]
n18[]
n19[]
n20[true_time = getattr(true_respons...]
n21[false_time = getattr(false_respon...]
n22{if true_time and false_time}
n23[time_diff = abs(true_time.total_...]
n24{if time_diff > 2.0}
n25[return True]
n26[]
n27[]
n28[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n27
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析布林回應以檢測SQL注入&#39;]
n4{if true_response.status_code !...}
n5[return True]
n6[]
n7[true_len = len(true_response.te...]
n8[false_len = len(false_response.t...]
n9[baseline_len = len(baseline.text or...]
n10{if abs(true_len - false_len) &gt; 50}
n11[return True]
n12[]
n13{if baseline_len &gt; 0}
n14[true_diff = abs(true_len - basel...]
n15[false_diff = abs(false_len - base...]
n16{if abs(true_diff - false_diff)...}
n17[return True]
n18[]
n19[]
n20[true_time = getattr(true_respons...]
n21[false_time = getattr(false_respon...]
n22{if true_time and false_time}
n23[time_diff = abs(true_time.total_...]
n24{if time_diff &gt; 2.0}
n25[return True]
n26[]
n27[]
n28[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n27
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
661. function function sqli aiva func sqli engines boolean detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
662. function function sqli aiva func sqli engines boolean detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n布林檢測引擎 - 基於布林邏輯的SQL注入檢測\n']
n4[from __future__ import annotations]
n5[import asyncio]
n6[from typing import cast]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class BooleanDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n布林檢測引擎 - 基於布林邏輯的SQL注入檢測\n&#39;]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from typing import cast]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class BooleanDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
663. function function sqli aiva func sqli engines error detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.error_patterns = {'mysql...]
n4[self.error_payloads = ["'&qu...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.error_patterns = {&#39;mysql&#3...]
n4[self.error_payloads = [&quot;&#39;&qu...]
n1 --> n3
n3 --> n4
n4 --> n2
664. function function sqli aiva func sqli engines error detection engine Function analyze error response
flowchart TB
n1([開始])
n2([結束])
n3['分析回應中的SQL錯誤']
n4{for (db_type, patterns) in self.error_patter...}
n5{for pattern in patterns}
n6{if re.search(pattern, response...}
n7[return (db_type, True)]
n8[]
n9[]
n10[]
n11[return ('unknown', False)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n4
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析回應中的SQL錯誤&#39;]
n4{for (db_type, patterns) in self.error_patter...}
n5{for pattern in patterns}
n6{if re.search(pattern, response...}
n7[return (db_type, True)]
n8[]
n9[]
n10[]
n11[return (&#39;unknown&#39;, False)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n4
n10 --> n11
n11 --> n2
665. function function sqli aiva func sqli engines error detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
666. function function sqli aiva func sqli engines error detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n錯誤檢測引擎 - 重構後的模組化版本\n']
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class ErrorDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n錯誤檢測引擎 - 重構後的模組化版本\n&#39;]
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class ErrorDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
667. function function sqli aiva func sqli engines oob detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.oast_domain = oast_domain]
n4[self.oob_payloads = {'mysql'...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.oast_domain = oast_domain]
n4[self.oob_payloads = {&#39;mysql&#39;...]
n1 --> n3
n3 --> n4
n4 --> n2
668. function function sqli aiva func sqli engines oob detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(requ...]
n8[impact = FindingImpact(busine...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(requ...]
n8[impact = FindingImpact(busine...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
669. function function sqli aiva func sqli engines oob detection engine Function check oob response
flowchart TB
n1([開始])
n2([結束])
n3['檢查回應中的OOB指示器']
n4[response_text = response.text or '']
n5{if subdomain in response_text}
n6[return True]
n7[]
n8[network_error_patterns = ['could not conn...]
n9{for pattern in network_error_pat...}
n10{if re.search(pattern, response...}
n11[return True]
n12[]
n13[]
n14[oob_error_patterns = ['xp_dirtree&...]
n15{for pattern in oob_error_patterns}
n16{if re.search(pattern, response...}
n17[return True]
n18[]
n19[]
n20[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n19
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n15
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查回應中的OOB指示器&#39;]
n4[response_text = response.text or &#39;&#39;]
n5{if subdomain in response_text}
n6[return True]
n7[]
n8[network_error_patterns = [&#39;could not conn...]
n9{for pattern in network_error_pat...}
n10{if re.search(pattern, response...}
n11[return True]
n12[]
n13[]
n14[oob_error_patterns = [&#39;xp_dirtree&...]
n15{for pattern in oob_error_patterns}
n16{if re.search(pattern, response...}
n17[return True]
n18[]
n19[]
n20[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n19
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n15
n19 --> n20
n20 --> n2
670. function function sqli aiva func sqli engines oob detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\nOut-of-Band (OOB) 檢測引擎 - 基於外帶通道的SQ...]
n4[from __future__ import annotations]
n5[import re]
n6[import uuid]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class OOBDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nOut-of-Band (OOB) 檢測引擎 - 基於外帶通道的SQ...]
n4[from __future__ import annotations]
n5[import re]
n6[import uuid]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class OOBDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
671. function function sqli aiva func sqli engines time detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.time_payloads = {'mysql'...]
n4[self.delay_threshold = 3.0]
n5[self.max_baseline_time = 2.0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.time_payloads = {&#39;mysql&#39...]
n4[self.delay_threshold = 3.0]
n5[self.max_baseline_time = 2.0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
672. function function sqli aiva func sqli engines time detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[delay = payload_time - basel...]
n7[confidence = min(0.9, delay / 5.0...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence = FindingEvidence(payl...]
n10[impact = FindingImpact(descri...]
n11[recommendation = FindingRecommendatio...]
n12[target = FindingTarget(url=ta...]
n13[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[delay = payload_time - basel...]
n7[confidence = min(0.9, delay / 5.0...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence = FindingEvidence(payl...]
n10[impact = FindingImpact(descri...]
n11[recommendation = FindingRecommendatio...]
n12[target = FindingTarget(url=ta...]
n13[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
673. function function sqli aiva func sqli engines time detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n時間檢測引擎 - 基於時間延遲的SQL注入檢測\n']
n4[from __future__ import annotations]
n5[import asyncio]
n6[import time]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class TimeDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n時間檢測引擎 - 基於時間延遲的SQL注入檢測\n&#39;]
n4[from __future__ import annotations]
n5[import asyncio]
n6[import time]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class TimeDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
674. function function sqli aiva func sqli engines union detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.union_payloads = ["' UNION ...]
n4[self.union_indicators = ['mysql.*version&...]
n5[self.column_count_errors = ['The used SEL...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.union_payloads = [&quot;&#39; UNION ...]
n4[self.union_indicators = [&#39;mysql.*version&...]
n5[self.column_count_errors = [&#39;The used SEL...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
675. function function sqli aiva func sqli engines union detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[confidence_map = {'union_success&...]
n7[confidence_score = confidence_map.get(d...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence_desc = f"UNION payload '...]
n10{if detection_type == 'union_su...}
n11[evidence_desc += 'successfully executed and r...]
n12{if detection_type == 'column_c...}
n13[evidence_desc += 'triggered column count mism...]
n14{if detection_type == 'content_...}
n15[evidence_desc += 'caused significant content ...]
n16[]
n17[]
n18[]
n19[evidence = FindingEvidence(requ...]
n20[impact = FindingImpact(busine...]
n21[recommendation = FindingRecommendatio...]
n22[target = FindingTarget(url=st...]
n23[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n18
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[confidence_map = {&#39;union_success&...]
n7[confidence_score = confidence_map.get(d...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence_desc = f&quot;UNION payload &#39;...]
n10{if detection_type == &#39;union_su...}
n11[evidence_desc += &#39;successfully executed and r...]
n12{if detection_type == &#39;column_c...}
n13[evidence_desc += &#39;triggered column count mism...]
n14{if detection_type == &#39;content_...}
n15[evidence_desc += &#39;caused significant content ...]
n16[]
n17[]
n18[]
n19[evidence = FindingEvidence(requ...]
n20[impact = FindingImpact(busine...]
n21[recommendation = FindingRecommendatio...]
n22[target = FindingTarget(url=st...]
n23[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n18
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
676. function function sqli aiva func sqli engines union detection engine Function check column count error
flowchart TB
n1([開始])
n2([結束])
n3['檢查欄位數量錯誤(表示UNION語法有效)']
n4{for pattern in self.column_count...}
n5{if re.search(pattern, content,...}
n6[return True]
n7[]
n8[]
n9[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查欄位數量錯誤(表示UNION語法有效)&#39;]
n4{for pattern in self.column_count...}
n5{if re.search(pattern, content,...}
n6[return True]
n7[]
n8[]
n9[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
677. function function sqli aiva func sqli engines union detection engine Function check content change
flowchart TB
n1([開始])
n2([結束])
n3['檢查內容變化(可能表示UNION成功)']
n4[baseline_len = len(baseline)]
n5[response_len = len(response)]
n6{if baseline_len > 0}
n7[length_diff = abs(response_len - b...]
n8{if length_diff > 0.2}
n9[return True]
n10[]
n11[]
n12[baseline_numbers = set(re.findall('\\...]
n13[response_numbers = set(re.findall('\\...]
n14[new_numbers = response_numbers - b...]
n15{if len(new_numbers) >= 2}
n16[sorted_numbers = sorted([int(n) for n...]
n17{if len(sorted_numbers) >= 2}
n18{for i in range(len(sorted_...}
n19{if sorted_numbers[i + 1] - sor...}
n20[return True]
n21[]
n22[]
n23[]
n24[]
n25[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n24
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n23
n18 -->|Yes| n19
n18 -->|No| n22
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n18
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查內容變化(可能表示UNION成功)&#39;]
n4[baseline_len = len(baseline)]
n5[response_len = len(response)]
n6{if baseline_len &gt; 0}
n7[length_diff = abs(response_len - b...]
n8{if length_diff &gt; 0.2}
n9[return True]
n10[]
n11[]
n12[baseline_numbers = set(re.findall(&#39;\\...]
n13[response_numbers = set(re.findall(&#39;\\...]
n14[new_numbers = response_numbers - b...]
n15{if len(new_numbers) &gt;= 2}
n16[sorted_numbers = sorted([int(n) for n...]
n17{if len(sorted_numbers) &gt;= 2}
n18{for i in range(len(sorted_...}
n19{if sorted_numbers[i + 1] - sor...}
n20[return True]
n21[]
n22[]
n23[]
n24[]
n25[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n24
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n23
n18 -->|Yes| n19
n18 -->|No| n22
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n18
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
678. function function sqli aiva func sqli engines union detection engine Function check union success
flowchart TB
n1([開始])
n2([結束])
n3['檢查UNION查詢是否成功']
n4[content_lower = content.lower()]
n5{for pattern in self.union_indica...}
n6{if re.search(pattern, content_...}
n7[return True]
n8[]
n9[]
n10[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查UNION查詢是否成功&#39;]
n4[content_lower = content.lower()]
n5{for pattern in self.union_indica...}
n6{if re.search(pattern, content_...}
n7[return True]
n8[]
n9[]
n10[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
679. function function sqli aiva func sqli engines union detection engine Function get detection type
flowchart TB
n1([開始])
n2([結束])
n3['確定檢測類型']
n4{if union_success}
n5[return 'union_success']
n6{if column_error}
n7[return 'column_count_error']
n8{if content_change}
n9[return 'content_change']
n10[return 'unknown']
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;確定檢測類型&#39;]
n4{if union_success}
n5[return &#39;union_success&#39;]
n6{if column_error}
n7[return &#39;column_count_error&#39;]
n8{if content_change}
n9[return &#39;content_change&#39;]
n10[return &#39;unknown&#39;]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
680. function function sqli aiva func sqli engines union detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n聯合檢測引擎 - 基於UNION查詢的SQL注入檢測\n']
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class UnionDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n聯合檢測引擎 - 基於UNION查詢的SQL注入檢測\n&#39;]
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class UnionDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
681. function function sqli aiva func sqli exceptions Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.result_data = result_data]
n4[super().__init__(f'Detection resu...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.result_data = result_data]
n4[super().__init__(f&#39;Detection resu...]
n1 --> n3
n3 --> n4
n4 --> n2
682. function function sqli aiva func sqli exceptions Function str
flowchart TB
n1([開始])
n2([結束])
n3[parts = [super(SqliError, se...]
n4{if self.url}
n5[parts.append(f'(URL: {self.url...]
n6[]
n7{if self.status_code}
n8[parts.append(f'(Status: {self.st...]
n9[]
n10[return ' '.join(parts)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[parts = [super(SqliError, se...]
n4{if self.url}
n5[parts.append(f&#39;(URL: {self.url&#...]
n6[]
n7{if self.status_code}
n8[parts.append(f&#39;(Status: {self.st...]
n9[]
n10[return &#39; &#39;.join(parts)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
683. function function sqli aiva func sqli exceptions Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 檢測專用異常類別\n提供具體的錯誤類型和詳細的錯誤信息\n&...]
n4[from __future__ import annotations]
n5[class SqliError(...)]
n6[class EngineExecutionError(...)]
n7[class PayloadGenerationError(...)]
n8[class ConfigurationError(...)]
n9[class NetworkError(...)]
n10[class TimeoutError(...)]
n11[class ValidationError(...)]
n12[class DetectionResultError(...)]
n13[SqliDetectionError = SqliError]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 檢測專用異常類別\n提供具體的錯誤類型和詳細的錯誤信息\n&...]
n4[from __future__ import annotations]
n5[class SqliError(...)]
n6[class EngineExecutionError(...)]
n7[class PayloadGenerationError(...)]
n8[class ConfigurationError(...)]
n9[class NetworkError(...)]
n10[class TimeoutError(...)]
n11[class ValidationError(...)]
n12[class DetectionResultError(...)]
n13[SqliDetectionError = SqliError]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
684. function function sqli aiva func sqli payload wrapper encoder Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n1 --> n3
n3 --> n2
685. function function sqli aiva func sqli payload wrapper encoder Function inject query
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parts = list(urlparse(url))]
n7[query_pairs = dict(parse_qsl(parts...]
n8[query_pairs[parameter] = value]
n9[parts[4] = urlencode(query_pair...]
n10[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parts = list(urlparse(url))]
n7[query_pairs = dict(parse_qsl(parts...]
n8[query_pairs[parameter] = value]
n9[parts[4] = urlencode(query_pair...]
n10[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
686. function function sqli aiva func sqli payload wrapper encoder Function build request dump
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f'{self.method} {...]
n4{if 'headers' in self.request_k...}
n5{for (key, value) in self.request_kwar...}
n6[lines.append(f'{key}: {val...]
n7[]
n8[]
n9[body_parts = []]
n10{if 'params' in self.request_kw...}
n11[body_parts.append(f"params={self.reques...]
n12[]
n13{if 'data' in self.request_kwargs}
n14[body_parts.append(f"data={self.request_...]
n15[]
n16{if 'json' in self.request_kwargs}
n17[body_parts.append(f"json={self.request_...]
n18[]
n19{if 'content' in self.request_k...}
n20[body_parts.append(f"content={self.reque...]
n21[]
n22{if body_parts}
n23[lines.append('\n'.join(bo...]
n24[]
n25[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f&#39;{self.method} {...]
n4{if &#39;headers&#39; in self.request_k...}
n5{for (key, value) in self.request_kwar...}
n6[lines.append(f&#39;{key}: {val...]
n7[]
n8[]
n9[body_parts = []]
n10{if &#39;params&#39; in self.request_kw...}
n11[body_parts.append(f&quot;params={self.reques...]
n12[]
n13{if &#39;data&#39; in self.request_kwargs}
n14[body_parts.append(f&quot;data={self.request_...]
n15[]
n16{if &#39;json&#39; in self.request_kwargs}
n17[body_parts.append(f&quot;json={self.request_...]
n18[]
n19{if &#39;content&#39; in self.request_k...}
n20[body_parts.append(f&quot;content={self.reque...]
n21[]
n22{if body_parts}
n23[lines.append(&#39;\n&#39;.join(bo...]
n24[]
n25[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n2
687. function function sqli aiva func sqli payload wrapper encoder Function encode
flowchart TB
n1([開始])
n2([結束])
n3['將 payload 編碼為目標請求格式']
n4[target = self._task.target]
n5[method = target.method.upper(...]
n6[headers = dict(target.headers)]
n7[cookies = dict(target.cookies)]
n8[location = (target.parameter_lo...]
n9[parameter = target.parameter]
n10[request_kwargs: dict[str, Any] = {&#...]
n11{if location == 'query'}
n12[base_params = dict(parse_qsl(urlpa...]
n13{if parameter}
n14[base_params[parameter] = payload]
n15[]
n16[request_kwargs['params'] ...]
n17[url = str(target.url)]
n18{if location == 'form' and meth...}
n19[data = dict(target.form_dat...]
n20{if parameter}
n21[data[parameter] = payload]
n22[]
n23[request_kwargs['data'] = ...]
n24[url = str(target.url)]
n25{if location == 'json' and meth...}
n26[json_payload = dict(target.json_dat...]
n27{if parameter}
n28[json_payload[parameter] = payload]
n29[]
n30[request_kwargs['json'] = ...]
n31[request_kwargs.setdefault('headers&...]
n32[url = str(target.url)]
n33{if location == 'body'}
n34[body = target.body or '']
n35[request_kwargs['content']...]
n36[url = str(target.url)]
n37[url = self._inject_query(s...]
n38[]
n39[]
n40[]
n41[]
n42[request_kwargs = {k: v for k, v in re...]
n43[return EncodedPayload(url=url, method...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n18
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n41
n18 -->|Yes| n19
n18 -->|No| n25
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n40
n25 -->|Yes| n26
n25 -->|No| n33
n26 --> n27
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n39
n33 -->|Yes| n34
n33 -->|No| n37
n34 --> n35
n35 --> n36
n36 --> n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將 payload 編碼為目標請求格式&#39;]
n4[target = self._task.target]
n5[method = target.method.upper(...]
n6[headers = dict(target.headers)]
n7[cookies = dict(target.cookies)]
n8[location = (target.parameter_lo...]
n9[parameter = target.parameter]
n10[request_kwargs: dict[str, Any] = {&#...]
n11{if location == &#39;query&#39;}
n12[base_params = dict(parse_qsl(urlpa...]
n13{if parameter}
n14[base_params[parameter] = payload]
n15[]
n16[request_kwargs[&#39;params&#39;] ...]
n17[url = str(target.url)]
n18{if location == &#39;form&#39; and meth...}
n19[data = dict(target.form_dat...]
n20{if parameter}
n21[data[parameter] = payload]
n22[]
n23[request_kwargs[&#39;data&#39;] = ...]
n24[url = str(target.url)]
n25{if location == &#39;json&#39; and meth...}
n26[json_payload = dict(target.json_dat...]
n27{if parameter}
n28[json_payload[parameter] = payload]
n29[]
n30[request_kwargs[&#39;json&#39;] = ...]
n31[request_kwargs.setdefault(&#39;headers&&#...]
n32[url = str(target.url)]
n33{if location == &#39;body&#39;}
n34[body = target.body or &#39;&#39;]
n35[request_kwargs[&#39;content&#39;]...]
n36[url = str(target.url)]
n37[url = self._inject_query(s...]
n38[]
n39[]
n40[]
n41[]
n42[request_kwargs = {k: v for k, v in re...]
n43[return EncodedPayload(url=url, method...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n18
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n41
n18 -->|Yes| n19
n18 -->|No| n25
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n40
n25 -->|Yes| n26
n25 -->|No| n33
n26 --> n27
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n39
n33 -->|Yes| n34
n33 -->|No| n37
n34 --> n35
n35 --> n36
n36 --> n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n2
688. function function sqli aiva func sqli payload wrapper encoder Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[from typing import Any]
n6[from urllib.parse import parse_qsl, urlencode, url...]
n7[from services.aiva_common.schemas import FunctionT...]
n8[class EncodedPayload(...)]
n9[class PayloadWrapperEncoder(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[from typing import Any]
n6[from urllib.parse import parse_qsl, urlencode, url...]
n7[from services.aiva_common.schemas import FunctionT...]
n8[class EncodedPayload(...)]
n9[class PayloadWrapperEncoder(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
689. function function sqli aiva func sqli result binder publisher Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or f'sqli-...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or f&#39;sqli-...]
n1 --> n3
n3 --> n4
n4 --> n2
690. function function sqli aiva func sqli result binder publisher Function worker id
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
691. function function sqli aiva func sqli result binder publisher Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[from typing import Any]
n6[import uuid]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class SqliResultBinderPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[from typing import Any]
n6[import uuid]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class SqliResultBinderPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
692. function function sqli aiva func sqli schemas Function str
flowchart TB
n1([開始])
n2([結束])
n3['字符串表示']
n4[payload_preview = self.payload[:50] + ...]
n5[return f'[{self.engine_name} ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;字符串表示&#39;]
n4[payload_preview = self.payload[:50] + ...]
n5[return f&#39;[{self.engine_name}	...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
693. function function sqli aiva func sqli schemas Function build request dump
flowchart TB
n1([開始])
n2([結束])
n3['構建請求轉儲字符串 - 用於日誌和證據']
n4[lines = [f'{self.method} {...]
n5{if 'headers' in self.request_k...}
n6{for (key, value) in self.request_kwar...}
n7[lines.append(f'{key}: {val...]
n8[]
n9[]
n10[body_parts = []]
n11{if 'params' in self.request_kw...}
n12[body_parts.append(f"params={self.reques...]
n13[]
n14{if 'data' in self.request_kwargs}
n15[body_parts.append(f"data={self.request_...]
n16[]
n17{if 'json' in self.request_kwargs}
n18[body_parts.append(f"json={self.request_...]
n19[]
n20{if 'content' in self.request_k...}
n21[body_parts.append(f"content={self.reque...]
n22[]
n23{if body_parts}
n24[lines.append('\n'.join(bo...]
n25[]
n26[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建請求轉儲字符串 - 用於日誌和證據&#39;]
n4[lines = [f&#39;{self.method} {...]
n5{if &#39;headers&#39; in self.request_k...}
n6{for (key, value) in self.request_kwar...}
n7[lines.append(f&#39;{key}: {val...]
n8[]
n9[]
n10[body_parts = []]
n11{if &#39;params&#39; in self.request_kw...}
n12[body_parts.append(f&quot;params={self.reques...]
n13[]
n14{if &#39;data&#39; in self.request_kwargs}
n15[body_parts.append(f&quot;data={self.request_...]
n16[]
n17{if &#39;json&#39; in self.request_kwargs}
n18[body_parts.append(f&quot;json={self.request_...]
n19[]
n20{if &#39;content&#39; in self.request_k...}
n21[body_parts.append(f&quot;content={self.reque...]
n22[]
n23{if body_parts}
n24[lines.append(&#39;\n&#39;.join(bo...]
n25[]
n26[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n2
694. function function sqli aiva func sqli schemas Function record detection
flowchart TB
n1([開始])
n2([結束])
n3['記錄檢測結果']
n4[self.detections += 1]
n5{if method == 'error'}
n6[self.error_based_detections += 1]
n7{if method == 'boolean'}
n8[self.blind_detections += 1]
n9{if method == 'time'}
n10[self.time_based_detections += 1]
n11{if method == 'union'}
n12[self.union_based_detections += 1]
n13{if method == 'oob'}
n14[self.oob_detections += 1]
n15[]
n16[]
n17[]
n18[]
n19[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n19
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n18
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄檢測結果&#39;]
n4[self.detections += 1]
n5{if method == &#39;error&#39;}
n6[self.error_based_detections += 1]
n7{if method == &#39;boolean&#39;}
n8[self.blind_detections += 1]
n9{if method == &#39;time&#39;}
n10[self.time_based_detections += 1]
n11{if method == &#39;union&#39;}
n12[self.union_based_detections += 1]
n13{if method == &#39;oob&#39;}
n14[self.oob_detections += 1]
n15[]
n16[]
n17[]
n18[]
n19[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n19
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n18
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
695. function function sqli aiva func sqli schemas Function record engine execution
flowchart TB
n1([開始])
n2([結束])
n3['記錄引擎執行']
n4{if engine_name not in self.eng...}
n5[self.engines_run.append(engine_name)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄引擎執行&#39;]
n4{if engine_name not in self.eng...}
n5[self.engines_run.append(engine_name)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
696. function function sqli aiva func sqli schemas Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤訊息']
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤訊息&#39;]
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
697. function function sqli aiva func sqli schemas Function record payload sent
flowchart TB
n1([開始])
n2([結束])
n3['記錄載荷發送']
n4[self.payloads_sent += 1]
n5[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄載荷發送&#39;]
n4[self.payloads_sent += 1]
n5[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
698. function function sqli aiva func sqli schemas Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式(覆蓋父類方法以添加 SQLi 特定信息)']
n4[details = super().to_details(f...]
n5[details.update({'engines_run&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式(覆蓋父類方法以添加 SQLi 特定信息)&#39;]
n4[details = super().to_details(f...]
n5[details.update({&#39;engines_run&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
699. function function sqli aiva func sqli schemas Function validate detection method
flowchart TB
n1([開始])
n2([結束])
n3['驗證檢測方法']
n4[allowed = {'error', &...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid detection_meth...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證檢測方法&#39;]
n4[allowed = {&#39;error&#39;, &...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid detection_meth...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
700. function function sqli aiva func sqli schemas Function validate method
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 方法']
n4[allowed = {'GET', &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f'Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 方法&#39;]
n4[allowed = {&#39;GET&#39;, &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f&#39;Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
701. function function sqli aiva func sqli schemas Function validate timeout
flowchart TB
n1([開始])
n2([結束])
n3['驗證超時設置']
n4{if 'time_threshold_seconds' in...}
n5[raise ValueError('timeout_seconds must be...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證超時設置&#39;]
n4{if &#39;time_threshold_seconds&#39; in...}
n5[raise ValueError(&#39;timeout_seconds must be...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
702. function function sqli aiva func sqli schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 模組專用數據合約\n定義 SQLi 檢測相關的所有數據結構,基於 Pyda...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingEv...]
n8[class SqliDetectionResult(...)]
n9[class SqliTelemetry(...)]
n10[class SqliEngineConfig(...)]
n11[class EncodedPayload(...)]
n12[class SqliDetectionContext(...)]
n13[class DetectionError(...)]
n14[DetectionResult = SqliDetectionResult]
n15[SqliExecutionTelemetry = SqliTelemetry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 模組專用數據合約\n定義 SQLi 檢測相關的所有數據結構,基於 Pyda...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingEv...]
n8[class SqliDetectionResult(...)]
n9[class SqliTelemetry(...)]
n10[class SqliEngineConfig(...)]
n11[class EncodedPayload(...)]
n12[class SqliDetectionContext(...)]
n13[class DetectionError(...)]
n14[DetectionResult = SqliDetectionResult]
n15[SqliExecutionTelemetry = SqliTelemetry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
703. function function sqli aiva func sqli smart detection manager Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
704. function function sqli aiva func sqli task queue Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._queue: asyncio.Queue[QueuedTask | None]...]
n4[self._closed = False]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._queue: asyncio.Queue[QueuedTask | None]...]
n4[self._closed = False]
n1 --> n3
n3 --> n4
n4 --> n2
705. function function sqli aiva func sqli task queue Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FunctionT...]
n7[class QueuedTask(...)]
n8[class SqliTaskQueue(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FunctionT...]
n7[class QueuedTask(...)]
n8[class SqliTaskQueue(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
706. function function sqli aiva func sqli telemetry Function add engine
flowchart TB
n1([開始])
n2([結束])
n3['記錄引擎執行(向後兼容別名)']
n4[self.record_engine_execution(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄引擎執行(向後兼容別名)&#39;]
n4[self.record_engine_execution(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
707. function function sqli aiva func sqli telemetry Function add error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤訊息(向後兼容別名)']
n4[self.record_error(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤訊息(向後兼容別名)&#39;]
n4[self.record_error(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
708. function function sqli aiva func sqli telemetry Function record detection
flowchart TB
n1([開始])
n2([結束])
n3['記錄檢測結果']
n4[self.detections += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄檢測結果&#39;]
n4[self.detections += 1]
n1 --> n3
n3 --> n4
n4 --> n2
709. function function sqli aiva func sqli telemetry Function record engine execution
flowchart TB
n1([開始])
n2([結束])
n3['記錄引擎執行']
n4[self.engines_run.append(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄引擎執行&#39;]
n4[self.engines_run.append(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
710. function function sqli aiva func sqli telemetry Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤訊息']
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤訊息&#39;]
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
711. function function sqli aiva func sqli telemetry Function record payload sent
flowchart TB
n1([開始])
n2([結束])
n3['記錄載荷發送']
n4[self.payloads_sent += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄載荷發送&#39;]
n4[self.payloads_sent += 1]
n1 --> n3
n3 --> n4
n4 --> n2
712. function function sqli aiva func sqli telemetry Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細的遙測報告格式']
n4[details: dict[str, object] = {'f...]
n5{if self.engines_run}
n6[details['engines'] = list...]
n7[]
n8{if self.errors}
n9[details['errors'] = self....]
n10[]
n11[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細的遙測報告格式&#39;]
n4[details: dict[str, object] = {&#39;f...]
n5{if self.engines_run}
n6[details[&#39;engines&#39;] = list...]
n7[]
n8{if self.errors}
n9[details[&#39;errors&#39;] = self....]
n10[]
n11[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
713. function function sqli aiva func sqli telemetry Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 執行遙測數據模型\n分離遙測邏輯以避免循環導入\n']
n4[from dataclasses import dataclass, field]
n5[class SqliExecutionTelemetry(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 執行遙測數據模型\n分離遙測邏輯以避免循環導入\n&#39;]
n4[from dataclasses import dataclass, field]
n5[class SqliExecutionTelemetry(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
714. function function sqli aiva func sqli worker Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
715. function function sqli aiva func sqli worker Function create config from strategy
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據掃描策略動態創建引擎配置\n\n Args:\n ...]
n4[strategy_upper = strategy.upper()]
n5{if strategy_upper == 'FAST'}
n6[return SqliEngineConfig(timeout_secon...]
n7{if strategy_upper == 'NORMAL'}
n8[return SqliEngineConfig(timeout_secon...]
n9{if strategy_upper == 'DEEP'}
n10[return SqliEngineConfig(timeout_secon...]
n11{if strategy_upper == 'AGGRESSIVE'}
n12[return SqliEngineConfig(timeout_secon...]
n13[logger.warning(f"Unknown strategy &#...]
n14[return SqliEngineConfig()]
n15[]
n16[]
n17[]
n18[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n18
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n17
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n16
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據掃描策略動態創建引擎配置\n\n Args:\n ...]
n4[strategy_upper = strategy.upper()]
n5{if strategy_upper == &#39;FAST&#39;}
n6[return SqliEngineConfig(timeout_secon...]
n7{if strategy_upper == &#39;NORMAL&#39;}
n8[return SqliEngineConfig(timeout_secon...]
n9{if strategy_upper == &#39;DEEP&#39;}
n10[return SqliEngineConfig(timeout_secon...]
n11{if strategy_upper == &#39;AGGRESSIVE&#39;}
n12[return SqliEngineConfig(timeout_secon...]
n13[logger.warning(f&quot;Unknown strategy &#...]
n14[return SqliEngineConfig()]
n15[]
n16[]
n17[]
n18[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n18
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n17
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n16
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
716. function function sqli aiva func sqli worker Function setup default engines
flowchart TB
n1([開始])
n2([結束])
n3['設置預設檢測引擎']
n4{if self.config.enable_error_de...}
n5[self.register_engine('error',...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine('boolean'...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine('time', ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine('union',...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine('oob', O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置預設檢測引擎&#39;]
n4{if self.config.enable_error_de...}
n5[self.register_engine(&#39;error&#39;,...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine(&#39;boolean&#39...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine(&#39;time&#39;, ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine(&#39;union&#39;,...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine(&#39;oob&#39;, O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
717. function function sqli aiva func sqli worker Function register engine
flowchart TB
n1([開始])
n2([結束])
n3['註冊檢測引擎']
n4[self._engines[name] = engine]
n5[logger.debug(f'Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊檢測引擎&#39;]
n4[self._engines[name] = engine]
n5[logger.debug(f&#39;Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
718. function function sqli aiva func sqli worker Function unregister engine
flowchart TB
n1([開始])
n2([結束])
n3['取消註冊檢測引擎']
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f'Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取消註冊檢測引擎&#39;]
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f&#39;Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
719. function function sqli aiva func sqli worker legacy Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
720. function function sqli aiva func sqli worker legacy Function setup default engines
flowchart TB
n1([開始])
n2([結束])
n3['設置預設檢測引擎']
n4{if self.config.enable_error_de...}
n5[self.register_engine('error',...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine('boolean'...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine('time', ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine('union',...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine('oob', O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置預設檢測引擎&#39;]
n4{if self.config.enable_error_de...}
n5[self.register_engine(&#39;error&#39;,...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine(&#39;boolean&#39...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine(&#39;time&#39;, ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine(&#39;union&#39;,...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine(&#39;oob&#39;, O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
721. function function sqli aiva func sqli worker legacy Function register engine
flowchart TB
n1([開始])
n2([結束])
n3['註冊檢測引擎']
n4[self._engines[name] = engine]
n5[logger.debug(f'Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊檢測引擎&#39;]
n4[self._engines[name] = engine]
n5[logger.debug(f&#39;Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
722. function function sqli aiva func sqli worker legacy Function unregister engine
flowchart TB
n1([開始])
n2([結束])
n3['取消註冊檢測引擎']
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f'Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取消註冊檢測引擎&#39;]
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f&#39;Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
723. function function sqli aiva func sqli worker legacy Module
flowchart TB
n1([開始])
n2([結束])
n3['\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliDetectionContext(...)]
n23[class SqliDetectionOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliDetectionContext(...)]
n23[class SqliDetectionOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
724. function function sqli aiva func sqli worker Module
flowchart TB
n1([開始])
n2([結束])
n3['\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliContext(...)]
n23[class SqliOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n29[SqliDetectionContext = SqliContext]
n30[SqliDetectionOrchestrator = SqliOrchestrator]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliContext(...)]
n23[class SqliOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n29[SqliDetectionContext = SqliContext]
n30[SqliDetectionOrchestrator = SqliOrchestrator]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
725. function function ssrf init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
726. function function ssrf aiva func ssrf init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
727. function function ssrf aiva func ssrf enhanced worker Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化增強版 SSRF 工作器\n\n Args:\n...]
n4[self.config = config or SSRFConfig...]
n5[self.smart_detector = SmartSSRFDetector(se...]
n6[logger.info('Enhanced SSRF Worker initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化增強版 SSRF 工作器\n\n Args:\n...]
n4[self.config = config or SSRFConfig...]
n5[self.smart_detector = SmartSSRFDetector(se...]
n6[logger.info(&#39;Enhanced SSRF Worker initial...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
728. function function ssrf aiva func ssrf enhanced worker Function convert to finding payloads
flowchart TB
n1([開始])
n2([結束])
n3['\n 轉換檢測結果為 FindingPayload 對象\n\n ...]
n4[findings = []]
n5{for finding_data in findings_data}
n6[finding_payload = FindingPayload(findi...]
n7[findings.append(finding_payload)]
n8[]
n9[return findings]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 轉換檢測結果為 FindingPayload 對象\n\n ...]
n4[findings = []]
n5{for finding_data in findings_data}
n6[finding_payload = FindingPayload(findi...]
n7[findings.append(finding_payload)]
n8[]
n9[return findings]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
729. function function ssrf aiva func ssrf enhanced worker Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細信息字典']
n4[details: dict[str, Any] = {'atte...]
n5{if self.errors}
n6[details['errors'] = self....]
n7[]
n8[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細信息字典&#39;]
n4[details: dict[str, Any] = {&#39;atte...]
n5{if self.errors}
n6[details[&#39;errors&#39;] = self....]
n7[]
n8[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
730. function function ssrf aiva func ssrf enhanced worker Module
flowchart TB
n1([開始])
n2([結束])
n3['\nEnhanced SSRF Worker - 增強版 SSRF 工作器\n整合智能檢...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[import httpx]
n8[from services.aiva_common.enums import Topic]
n9[from services.aiva_common.mq import get_broker]
n10[from services.aiva_common.schemas import AivaMessa...]
n11[from services.aiva_common.utils import get_logger]
n12[from services.function.common.detection_config imp...]
n13[from services.function.common.worker_statistics im...]
n14[from .internal_address_detector import InternalAdd...]
n15[from .oast_dispatcher import OastDispatcher]
n16[from .param_semantics_analyzer import ParamSemanti...]
n17[from .result_publisher import SsrfResultPublisher]
n18[from .smart_ssrf_detector import SmartSSRFDetector]
n19[logger = get_logger(__name__)]
n20[DEFAULT_TIMEOUT_SECONDS = 15.0]
n21[class EnhancedSsrfTelemetry(...)]
n22[class EnhancedTaskExecutionResult(...)]
n23[class EnhancedSSRFWorker(...)]
n24[def run(...)]
n25[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nEnhanced SSRF Worker - 增強版 SSRF 工作器\n整合智能檢...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[import httpx]
n8[from services.aiva_common.enums import Topic]
n9[from services.aiva_common.mq import get_broker]
n10[from services.aiva_common.schemas import AivaMessa...]
n11[from services.aiva_common.utils import get_logger]
n12[from services.function.common.detection_config imp...]
n13[from services.function.common.worker_statistics im...]
n14[from .internal_address_detector import InternalAdd...]
n15[from .oast_dispatcher import OastDispatcher]
n16[from .param_semantics_analyzer import ParamSemanti...]
n17[from .result_publisher import SsrfResultPublisher]
n18[from .smart_ssrf_detector import SmartSSRFDetector]
n19[logger = get_logger(__name__)]
n20[DEFAULT_TIMEOUT_SECONDS = 15.0]
n21[class EnhancedSsrfTelemetry(...)]
n22[class EnhancedTaskExecutionResult(...)]
n23[class EnhancedSSRFWorker(...)]
n24[def run(...)]
n25[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
731. function function ssrf aiva func ssrf internal address detector Function assess risk level
flowchart TB
n1([開始])
n2([結束])
n3[risk_score = 0]
n4{if results.get('accessible_add...}
n5[risk_score += len(results['accessible...]
n6[]
n7{if results.get('cloud_metadata...}
n8[risk_score += len(results['cloud_meta...]
n9[]
n10{if results.get('internal_servi...}
n11[risk_score += len(results['internal_s...]
n12[]
n13{if results.get('protocol_suppo...}
n14[risk_score += len(results['protocol_s...]
n15[]
n16{if risk_score >= 10}
n17[return 'critical']
n18{if risk_score >= 6}
n19[return 'high']
n20{if risk_score >= 3}
n21[return 'medium']
n22{if risk_score >= 1}
n23[return 'low']
n24[return 'info']
n25[]
n26[]
n27[]
n28[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n28
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n27
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n26
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n25
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[risk_score = 0]
n4{if results.get(&#39;accessible_add...}
n5[risk_score += len(results[&#39;accessible...]
n6[]
n7{if results.get(&#39;cloud_metadata...}
n8[risk_score += len(results[&#39;cloud_meta...]
n9[]
n10{if results.get(&#39;internal_servi...}
n11[risk_score += len(results[&#39;internal_s...]
n12[]
n13{if results.get(&#39;protocol_suppo...}
n14[risk_score += len(results[&#39;protocol_s...]
n15[]
n16{if risk_score &gt;= 10}
n17[return &#39;critical&#39;]
n18{if risk_score &gt;= 6}
n19[return &#39;high&#39;]
n20{if risk_score &gt;= 3}
n21[return &#39;medium&#39;]
n22{if risk_score &gt;= 1}
n23[return &#39;low&#39;]
n24[return &#39;info&#39;]
n25[]
n26[]
n27[]
n28[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n28
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n27
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n26
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n25
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
732. function function ssrf aiva func ssrf internal address detector Function generate evidence
flowchart TB
n1([開始])
n2([結束])
n3[evidence: list[str] = []]
n4{if results.get('accessible_add...}
n5[count = len(results['accessi...]
n6[evidence.append(f'Discovered {count&...]
n7[]
n8{if results.get('cloud_metadata...}
n9[providers = {item['provider&#...]
n10[evidence.append(f"Observed cloud metadata re...]
n11[]
n12{if results.get('internal_servi...}
n13[services = [item['service_type&...]
n14[evidence.append(f"Detected internal services...]
n15[]
n16{if results.get('protocol_suppo...}
n17[protocols = results['protocol_su...]
n18[evidence.append(f"Supported protocols: {...]
n19[]
n20[return evidence]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[evidence: list[str] = []]
n4{if results.get(&#39;accessible_add...}
n5[count = len(results[&#39;accessi...]
n6[evidence.append(f&#39;Discovered {count&...]
n7[]
n8{if results.get(&#39;cloud_metadata...}
n9[providers = {item[&#39;provider&#...]
n10[evidence.append(f&quot;Observed cloud metadata re...]
n11[]
n12{if results.get(&#39;internal_servi...}
n13[services = [item[&#39;service_type&&#...]
n14[evidence.append(f&quot;Detected internal services...]
n15[]
n16{if results.get(&#39;protocol_suppo...}
n17[protocols = results[&#39;protocol_su...]
n18[evidence.append(f&quot;Supported protocols: {...]
n19[]
n20[return evidence]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
733. function function ssrf aiva func ssrf internal address detector Function identify service type
flowchart TB
n1([開始])
n2([結束])
n3[service_map = {21: 'FTP', 22...]
n4[return service_map.get(port, f'Unknow...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[service_map = {21: &#39;FTP&#39;, 22...]
n4[return service_map.get(port, f&#39;Unknow...]
n1 --> n3
n3 --> n4
n4 --> n2
734. function function ssrf aiva func ssrf internal address detector Function is metadata response
flowchart TB
n1([開始])
n2([結束])
n3['\n Verify if the response body contai...]
n4{if not response}
n5[return False]
n6[]
n7[metadata_indicators = {'aws'...]
n8[indicators = metadata_indicators....]
n9[response_lower = response.lower()]
n10[return any((indicator.lower() in resp...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Verify if the response body contai...]
n4{if not response}
n5[return False]
n6[]
n7[metadata_indicators = {&#39;aws&#39;...]
n8[indicators = metadata_indicators....]
n9[response_lower = response.lower()]
n10[return any((indicator.lower() in resp...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
735. function function ssrf aiva func ssrf internal address detector Function is protocol supported
flowchart TB
n1([開始])
n2([結束])
n3{if not response}
n4[return False]
n5[]
n6[protocol_indicators = {'file://&#...]
n7[indicators = protocol_indicators....]
n8{if not indicators}
n9[return True]
n10[]
n11[response_lower = response.lower()]
n12[return any((indicator in response_low...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not response}
n4[return False]
n5[]
n6[protocol_indicators = {&#39;file://&#...]
n7[indicators = protocol_indicators....]
n8{if not indicators}
n9[return True]
n10[]
n11[response_lower = response.lower()]
n12[return any((indicator in response_low...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
736. function function ssrf aiva func ssrf internal address detector Function is service response
flowchart TB
n1([開始])
n2([結束])
n3['\n Verify if the response matches heu...]
n4{if not response}
n5[return False]
n6[]
n7[service_indicators = {21: ['ftp&...]
n8[indicators = service_indicators.g...]
n9[response_lower = response.lower()]
n10[return any((indicator in response_low...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Verify if the response matches heu...]
n4{if not response}
n5[return False]
n6[]
n7[service_indicators = {21: [&#39;ftp&...]
n8[indicators = service_indicators.g...]
n9[response_lower = response.lower()]
n10[return any((indicator in response_low...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
737. function function ssrf aiva func ssrf internal address detector Function is successful response
flowchart TB
n1([開始])
n2([結束])
n3['\n Determine whether the supplied res...]
n4{if not response}
n5[return False]
n6[]
n7[success_indicators = ['<html&&...]
n8[response_lower = response.lower()]
n9[return any((indicator in response_low...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n Determine whether the supplied res...]
n4{if not response}
n5[return False]
n6[]
n7[success_indicators = [&#39;&lt;html&&...]
n8[response_lower = response.lower()]
n9[return any((indicator in response_low...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
738. function function ssrf aiva func ssrf internal address detector Function test internal services
flowchart TB
n1([開始])
n2([結束])
n3['Probe common internal service ports using th...]
n4[detected_services: list[dict[str, Any]] =...]
n5[test_host = '127.0.0.1']
n6{for port in self._internal_se...}
n7[try]
n8[test_url = f'http://{test_host}...]
n9[response = test_function(url, p...]
n10{if self._is_service_response(r...}
n11[service_type = self._identify_servi...]
n12[detected_services.append({'host&...]
n13[logger.info(f'Internal service detected: ...]
n14[]
n15[]
n16[except Exception]
n17[logger.debug(f'Error testing port {p...]
n18[continue]
n19[]
n20[return detected_services]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n19
n7 --> n8
n7 --> n16
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n6
n16 --> n17
n17 --> n18
n18 --> n15
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Probe common internal service ports using th...]
n4[detected_services: list[dict[str, Any]] =...]
n5[test_host = &#39;127.0.0.1&#39;]
n6{for port in self._internal_se...}
n7[try]
n8[test_url = f&#39;http://{test_host}...]
n9[response = test_function(url, p...]
n10{if self._is_service_response(r...}
n11[service_type = self._identify_servi...]
n12[detected_services.append({&#39;host&...]
n13[logger.info(f&#39;Internal service detected: ...]
n14[]
n15[]
n16[except Exception]
n17[logger.debug(f&#39;Error testing port {p...]
n18[continue]
n19[]
n20[return detected_services]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n19
n7 --> n8
n7 --> n16
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n6
n16 --> n17
n17 --> n18
n18 --> n15
n19 --> n20
n20 --> n2
739. function function ssrf aiva func ssrf internal address detector Function test protocol support
flowchart TB
n1([開始])
n2([結束])
n3['Check whether special protocol schemes are h...]
n4[supported_protocols: list[str] = []]
n5{for protocol in self._special_pro...}
n6[try]
n7[test_url = f'{protocol}127.0.0....]
n8[response = test_function(url, p...]
n9{if self._is_protocol_supported...}
n10[supported_protocols.append(protocol.removesuffix(...]
n11[logger.info(f'Protocol support detected: ...]
n12[]
n13[]
n14[except Exception]
n15[logger.debug(f'Error testing protocol ...]
n16[continue]
n17[]
n18[return supported_protocols]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 --> n7
n6 --> n14
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n5
n14 --> n15
n15 --> n16
n16 --> n13
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Check whether special protocol schemes are h...]
n4[supported_protocols: list[str] = []]
n5{for protocol in self._special_pro...}
n6[try]
n7[test_url = f&#39;{protocol}127.0.0....]
n8[response = test_function(url, p...]
n9{if self._is_protocol_supported...}
n10[supported_protocols.append(protocol.removesuffix(...]
n11[logger.info(f&#39;Protocol support detected: ...]
n12[]
n13[]
n14[except Exception]
n15[logger.debug(f&#39;Error testing protocol ...]
n16[continue]
n17[]
n18[return supported_protocols]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 --> n7
n6 --> n14
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n5
n14 --> n15
n15 --> n16
n16 --> n13
n17 --> n18
n18 --> n2
740. function function ssrf aiva func ssrf internal address detector Function analyze
flowchart TB
n1([開始])
n2([結束])
n3['Analyze a probe response and return structur...]
n4[text = response.text if isi...]
n5[indicators: list[InternalIndicator] = []]
n6[ips = set(re.findall('\\b(...]
n7{for ip in ips}
n8{if self.is_internal_address(ip)}
n9[indicators.append(InternalIndicator(source=&&...]
n10[]
n11[]
n12{for provider in ('aws', &...}
n13{if self._is_metadata_response(...}
n14[indicators.append(InternalIndicator(source=&&...]
n15[]
n16[]
n17{for protocol in self._special_pro...}
n18{if self._is_protocol_supported...}
n19[indicators.append(InternalIndicator(source=&&...]
n20[]
n21[]
n22{if '169.254.169.254' in text}
n23[indicators.append(InternalIndicator(source=&&...]
n24[]
n25[matched = len(indicators) > 0]
n26[return InternalAddressDetection(match...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n12
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n17
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Analyze a probe response and return structur...]
n4[text = response.text if isi...]
n5[indicators: list[InternalIndicator] = []]
n6[ips = set(re.findall(&#39;\\b(...]
n7{for ip in ips}
n8{if self.is_internal_address(ip)}
n9[indicators.append(InternalIndicator(source=&&...]
n10[]
n11[]
n12{for provider in (&#39;aws&#39;, &...}
n13{if self._is_metadata_response(...}
n14[indicators.append(InternalIndicator(source=&&...]
n15[]
n16[]
n17{for protocol in self._special_pro...}
n18{if self._is_protocol_supported...}
n19[indicators.append(InternalIndicator(source=&&...]
n20[]
n21[]
n22{if &#39;169.254.169.254&#39; in text}
n23[indicators.append(InternalIndicator(source=&&...]
n24[]
n25[matched = len(indicators) &gt; 0]
n26[return InternalAddressDetection(match...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n12
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n17
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
741. function function ssrf aiva func ssrf internal address detector Function is internal address
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4[ip = ipaddress.ip_address...]
n5{for range_str in self._internal_ra...}
n6{if ip in ipaddress.ip_network(...}
n7[return True]
n8[]
n9[]
n10[]
n11[except ValueError]
n12[internal_domains = ['localhost...]
n13[return any((domain in address.lower()...]
n14[return False]
n1 --> n3
n3 --> n4
n3 --> n11
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n14
n11 --> n12
n12 --> n13
n13 --> n10
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4[ip = ipaddress.ip_address...]
n5{for range_str in self._internal_ra...}
n6{if ip in ipaddress.ip_network(...}
n7[return True]
n8[]
n9[]
n10[]
n11[except ValueError]
n12[internal_domains = [&#39;localhost&#3...]
n13[return any((domain in address.lower()...]
n14[return False]
n1 --> n3
n3 --> n4
n3 --> n11
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n14
n11 --> n12
n12 --> n13
n13 --> n10
n14 --> n2
742. function function ssrf aiva func ssrf internal address detector Function summary
flowchart TB
n1([開始])
n2([結束])
n3{if not self.indicators}
n4[return 'No indicators collected']
n5[]
n6[return '; '.join((f&&...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not self.indicators}
n4[return &#39;No indicators collected&#39;]
n5[]
n6[return &#39;; &#39;.join((f&&...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
743. function function ssrf aiva func ssrf internal address detector Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Callable]
n5[from dataclasses import dataclass, field]
n6[import ipaddress]
n7[import re]
n8[from typing import Any]
n9[import httpx]
n10[from services.aiva_common.utils import get_logger]
n11[logger = get_logger(__name__)]
n12[class InternalIndicator(...)]
n13[class InternalAddressDetection(...)]
n14[class InternalAddressDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Callable]
n5[from dataclasses import dataclass, field]
n6[import ipaddress]
n7[import re]
n8[from typing import Any]
n9[import httpx]
n10[from services.aiva_common.utils import get_logger]
n11[logger = get_logger(__name__)]
n12[class InternalIndicator(...)]
n13[class InternalAddressDetection(...)]
n14[class InternalAddressDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
744. function function ssrf aiva func ssrf oast dispatcher Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._base_url = (base_url or os.gete...]
n4[self._client = client]
n5[self._timeout = timeout]
n6[self._tokens: dict[str, OastProbe] = {}]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._base_url = (base_url or os.gete...]
n4[self._client = client]
n5[self._timeout = timeout]
n6[self._tokens: dict[str, OastProbe] = {}]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
745. function function ssrf aiva func ssrf oast dispatcher Function resolve token
flowchart TB
n1([開始])
n2([結束])
n3{if token in self._tokens}
n4[return self._tokens[token].token]
n5[]
n6[normalized = token.rstrip('/'...]
n7{for probe in self._tokens.valu...}
n8{if not isinstance(probe, OastP...}
n9[continue]
n10[]
n11{if normalized.startswith(probe...}
n12[return probe.token]
n13[]
n14[]
n15[parts = normalized.split('/'...]
n16[return parts[-1] if parts else token]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n14
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n7
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if token in self._tokens}
n4[return self._tokens[token].token]
n5[]
n6[normalized = token.rstrip(&#39;/&#39;...]
n7{for probe in self._tokens.valu...}
n8{if not isinstance(probe, OastP...}
n9[continue]
n10[]
n11{if normalized.startswith(probe...}
n12[return probe.token]
n13[]
n14[]
n15[parts = normalized.split(&#39;/&#39;...]
n16[return parts[-1] if parts else token]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n14
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n7
n14 --> n15
n15 --> n16
n16 --> n2
746. function function ssrf aiva func ssrf oast dispatcher Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[import json]
n6[import os]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[class OastProbe(...)]
n10[class OastEvent(...)]
n11[class OastDispatcher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[import json]
n6[import os]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[class OastProbe(...)]
n10[class OastEvent(...)]
n11[class OastDispatcher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
747. function function ssrf aiva func ssrf param semantics analyzer Function build payloads
flowchart TB
n1([開始])
n2([結束])
n3[seen = set()]
n4{for payload in task.custom_paylo...}
n5[normalized = payload.strip()]
n6{if normalized and normalized n...}
n7[seen.add(normalized)]
n8[yield normalized]
n9[]
n10[]
n11{for payload in task.test_config....}
n12[normalized = payload.strip()]
n13{if normalized and normalized n...}
n14[seen.add(normalized)]
n15[yield normalized]
n16[]
n17[]
n18{for payload in task.test_config....}
n19[normalized = payload.strip()]
n20{if normalized and normalized.l...}
n21[continue]
n22[]
n23{if normalized and normalized n...}
n24[seen.add(normalized)]
n25[yield normalized]
n26[]
n27[]
n28{for payload in self._DEFAULT_PAY...}
n29{if payload not in seen}
n30[seen.add(payload)]
n31[yield payload]
n32[]
n33[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n4
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n17
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n11
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n27
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n26
n24 --> n25
n25 --> n26
n26 --> n18
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n33
n29 -->|Yes| n30
n29 -->|No| n32
n30 --> n31
n31 --> n32
n32 --> n28
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[seen = set()]
n4{for payload in task.custom_paylo...}
n5[normalized = payload.strip()]
n6{if normalized and normalized n...}
n7[seen.add(normalized)]
n8[yield normalized]
n9[]
n10[]
n11{for payload in task.test_config....}
n12[normalized = payload.strip()]
n13{if normalized and normalized n...}
n14[seen.add(normalized)]
n15[yield normalized]
n16[]
n17[]
n18{for payload in task.test_config....}
n19[normalized = payload.strip()]
n20{if normalized and normalized.l...}
n21[continue]
n22[]
n23{if normalized and normalized n...}
n24[seen.add(normalized)]
n25[yield normalized]
n26[]
n27[]
n28{for payload in self._DEFAULT_PAY...}
n29{if payload not in seen}
n30[seen.add(payload)]
n31[yield payload]
n32[]
n33[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n4
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n17
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n11
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n27
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n26
n24 --> n25
n25 --> n26
n26 --> n18
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n33
n29 -->|Yes| n30
n29 -->|No| n32
n30 --> n31
n31 --> n32
n32 --> n28
n33 --> n2
748. function function ssrf aiva func ssrf param semantics analyzer Function should enable oast
flowchart TB
n1([開始])
n2([結束])
n3[token_set = set(tokens)]
n4{if {'callback', '...}
n5[return True]
n6[]
n7{if {'notify', 'p...}
n8[return True]
n9[]
n10[payload_sources: list[str] = []]
n11{if task.custom_payloads}
n12[payload_sources.extend(task.custom_payloads)]
n13[]
n14[payload_sources.extend(task.test_config.custom_pay...]
n15{if payload_sources}
n16[return any((OAST_PLACEHOLDER in paylo...]
n17[]
n18[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[token_set = set(tokens)]
n4{if {&#39;callback&#39;, &#39...}
n5[return True]
n6[]
n7{if {&#39;notify&#39;, &#39;p...}
n8[return True]
n9[]
n10[payload_sources: list[str] = []]
n11{if task.custom_payloads}
n12[payload_sources.extend(task.custom_payloads)]
n13[]
n14[payload_sources.extend(task.test_config.custom_pay...]
n15{if payload_sources}
n16[return any((OAST_PLACEHOLDER in paylo...]
n17[]
n18[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
749. function function ssrf aiva func ssrf param semantics analyzer Function tokenize
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return set()]
n5[]
n6[normalized = re.sub('([A-Z]...]
n7[parts = re.split('[^a-z0-9]+...]
n8[return {part for part in parts if par...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return set()]
n5[]
n6[normalized = re.sub(&#39;([A-Z]&#...]
n7[parts = re.split(&#39;[^a-z0-9]+...]
n8[return {part for part in parts if par...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
750. function function ssrf aiva func ssrf param semantics analyzer Function analyze
flowchart TB
n1([開始])
n2([結束])
n3[parameter = (task.target.paramet...]
n4[location = (task.target.paramet...]
n5[tokens = self._tokenize(param...]
n6[plan = AnalysisPlan()]
n7[payloads = list(self._build_pay...]
n8[requires_redirect = bool(self._REDIRECT_...]
n9[requires_file = bool(self._FILE_KEYW...]
n10[requires_protocol = bool(self._PROTOCOL_...]
n11{if not payloads}
n12[payloads = list(self._DEFAULT_P...]
n13[]
n14{for payload in payloads}
n15[plan.vectors.append(SsrfTestVector(payload=payloa...]
n16[]
n17{if requires_redirect}
n18[plan.vectors.append(SsrfTestVector(payload=&&...]
n19[]
n20{if requires_file}
n21{for payload in self._FILE_PAYLOADS}
n22[plan.vectors.append(SsrfTestVector(payload=payloa...]
n23[]
n24[]
n25{if requires_protocol}
n26{for payload in self._PROTOCOL_PA...}
n27[plan.vectors.append(SsrfTestVector(payload=payloa...]
n28[]
n29[]
n30[requested = {p.strip().lower() f...]
n31[headers = task.target.headers ...]
n32[protocols_hdr = headers.get('X-SSRF-...]
n33[selected_protocols: set[str] = set()]
n34{if protocols_hdr}
n35[selected_protocols = {p.strip().lower(...]
n36{if {'cross', 'ad...}
n37[selected_protocols = {'gopher...]
n38[]
n39[]
n40{for proto in selected_protocols}
n41{for payload in self._CROSS_PROTO...}
n42[plan.vectors.append(SsrfTestVector(payload=payloa...]
n43[]
n44[]
n45{if self._should_enable_oast(to...}
n46[plan.vectors.append(SsrfTestVector(payload=f&...]
n47[]
n48[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n14
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n24
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n21
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n29
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n26
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n39
n36 -->|Yes| n37
n36 -->|No| n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 -->|Yes| n41
n40 -->|No| n44
n41 -->|Yes| n42
n41 -->|No| n43
n42 --> n41
n43 --> n40
n44 --> n45
n45 -->|Yes| n46
n45 -->|No| n47
n46 --> n47
n47 --> n48
n48 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[parameter = (task.target.paramet...]
n4[location = (task.target.paramet...]
n5[tokens = self._tokenize(param...]
n6[plan = AnalysisPlan()]
n7[payloads = list(self._build_pay...]
n8[requires_redirect = bool(self._REDIRECT_...]
n9[requires_file = bool(self._FILE_KEYW...]
n10[requires_protocol = bool(self._PROTOCOL_...]
n11{if not payloads}
n12[payloads = list(self._DEFAULT_P...]
n13[]
n14{for payload in payloads}
n15[plan.vectors.append(SsrfTestVector(payload=payloa...]
n16[]
n17{if requires_redirect}
n18[plan.vectors.append(SsrfTestVector(payload=&&...]
n19[]
n20{if requires_file}
n21{for payload in self._FILE_PAYLOADS}
n22[plan.vectors.append(SsrfTestVector(payload=payloa...]
n23[]
n24[]
n25{if requires_protocol}
n26{for payload in self._PROTOCOL_PA...}
n27[plan.vectors.append(SsrfTestVector(payload=payloa...]
n28[]
n29[]
n30[requested = {p.strip().lower() f...]
n31[headers = task.target.headers ...]
n32[protocols_hdr = headers.get(&#39;X-SSRF-...]
n33[selected_protocols: set[str] = set()]
n34{if protocols_hdr}
n35[selected_protocols = {p.strip().lower(&#...]
n36{if {&#39;cross&#39;, &#39;ad...}
n37[selected_protocols = {&#39;gopher&#3...]
n38[]
n39[]
n40{for proto in selected_protocols}
n41{for payload in self._CROSS_PROTO...}
n42[plan.vectors.append(SsrfTestVector(payload=payloa...]
n43[]
n44[]
n45{if self._should_enable_oast(to...}
n46[plan.vectors.append(SsrfTestVector(payload=f&...]
n47[]
n48[return plan]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n14
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n24
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n21
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n29
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n26
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n39
n36 -->|Yes| n37
n36 -->|No| n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 -->|Yes| n41
n40 -->|No| n44
n41 -->|Yes| n42
n41 -->|No| n43
n42 --> n41
n43 --> n40
n44 --> n45
n45 -->|Yes| n46
n45 -->|No| n47
n46 --> n47
n47 --> n48
n48 --> n2
751. function function ssrf aiva func ssrf param semantics analyzer Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Collection, Iterable]
n5[from dataclasses import dataclass, field]
n6[import re]
n7[from services.aiva_common.schemas import FunctionT...]
n8[OAST_PLACEHOLDER = '{oast}&#...]
n9[class SsrfTestVector(...)]
n10[class AnalysisPlan(...)]
n11[class ParamSemanticsAnalyzer(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Collection, Iterable]
n5[from dataclasses import dataclass, field]
n6[import re]
n7[from services.aiva_common.schemas import FunctionT...]
n8[OAST_PLACEHOLDER = &#39;{oast}&#...]
n9[class SsrfTestVector(...)]
n10[class AnalysisPlan(...)]
n11[class ParamSemanticsAnalyzer(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
752. function function ssrf aiva func ssrf result publisher Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or os.gete...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or os.gete...]
n1 --> n3
n3 --> n4
n4 --> n2
753. function function ssrf aiva func ssrf result publisher Function worker id
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
754. function function ssrf aiva func ssrf result publisher Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[import os]
n6[from typing import Any]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class SsrfResultPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[import os]
n6[from typing import Any]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class SsrfResultPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
755. function function ssrf aiva func ssrf schemas Function init
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(**data)]
n4{if self.estimated_tests == 0}
n5[self.estimated_tests = len(self.vectors)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(**data)]
n4{if self.estimated_tests == 0}
n5[self.estimated_tests = len(self.vectors)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
756. function function ssrf aiva func ssrf schemas Function record cloud metadata access
flowchart TB
n1([開始])
n2([結束])
n3['記錄雲元數據訪問']
n4[self.cloud_metadata_access += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄雲元數據訪問&#39;]
n4[self.cloud_metadata_access += 1]
n1 --> n3
n3 --> n4
n4 --> n2
757. function function ssrf aiva func ssrf schemas Function record dns lookup
flowchart TB
n1([開始])
n2([結束])
n3['記錄 DNS 查找']
n4[self.dns_lookups += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 DNS 查找&#39;]
n4[self.dns_lookups += 1]
n1 --> n3
n3 --> n4
n4 --> n2
758. function function ssrf aiva func ssrf schemas Function record internal access
flowchart TB
n1([開始])
n2([結束])
n3['記錄內部訪問']
n4[self.internal_access += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄內部訪問&#39;]
n4[self.internal_access += 1]
n1 --> n3
n3 --> n4
n4 --> n2
759. function function ssrf aiva func ssrf schemas Function record oast callback
flowchart TB
n1([開始])
n2([結束])
n3['記錄 OAST 回調']
n4[self.oast_callbacks += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 OAST 回調&#39;]
n4[self.oast_callbacks += 1]
n1 --> n3
n3 --> n4
n4 --> n2
760. function function ssrf aiva func ssrf schemas Function record protocol
flowchart TB
n1([開始])
n2([結束])
n3['記錄測試的協議']
n4{if protocol not in self.protoc...}
n5[self.protocols_tested.append(protocol)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄測試的協議&#39;]
n4{if protocol not in self.protoc...}
n5[self.protocols_tested.append(protocol)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
761. function function ssrf aiva func ssrf schemas Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式']
n4[details = super().to_details(f...]
n5[details.update({'oast_callbacks&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式&#39;]
n4[details = super().to_details(f...]
n5[details.update({&#39;oast_callbacks&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
762. function function ssrf aiva func ssrf schemas Function validate protocol
flowchart TB
n1([開始])
n2([結束])
n3['驗證協議']
n4[allowed = {'http', &#...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid protocol: ...]
n7[]
n8[return v.lower()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證協議&#39;]
n4[allowed = {&#39;http&#39;, &#...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid protocol: ...]
n7[]
n8[return v.lower()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
763. function function ssrf aiva func ssrf schemas Function validate vector type
flowchart TB
n1([開始])
n2([結束])
n3['驗證向量類型']
n4[allowed = {'internal', &...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid vector_type: &...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證向量類型&#39;]
n4[allowed = {&#39;internal&#39;, &...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid vector_type: &...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
764. function function ssrf aiva func ssrf schemas Function validate vectors
flowchart TB
n1([開始])
n2([結束])
n3['驗證測試向量']
n4{if not v}
n5[raise ValueError('At least one test vecto...]
n6[]
n7{if len(v) > 1000}
n8[raise ValueError('Too many test vectors &...]
n9[]
n10[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證測試向量&#39;]
n4{if not v}
n5[raise ValueError(&#39;At least one test vecto...]
n6[]
n7{if len(v) &gt; 1000}
n8[raise ValueError(&#39;Too many test vectors &...]
n9[]
n10[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
765. function function ssrf aiva func ssrf schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSSRF 模組專用數據合約\n定義 SSRF 檢測相關的所有數據結構,基於 Pyda...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingPa...]
n8[class SsrfTestVector(...)]
n9[class AnalysisPlan(...)]
n10[class SsrfTelemetry(...)]
n11[class TaskExecutionResult(...)]
n12[class InternalAddressDetectionResult(...)]
n13[__all__ = ['SsrfTestVector', ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSSRF 模組專用數據合約\n定義 SSRF 檢測相關的所有數據結構,基於 Pyda...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingPa...]
n8[class SsrfTestVector(...)]
n9[class AnalysisPlan(...)]
n10[class SsrfTelemetry(...)]
n11[class TaskExecutionResult(...)]
n12[class InternalAddressDetectionResult(...)]
n13[__all__ = [&#39;SsrfTestVector&#39;, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
766. function function ssrf aiva func ssrf smart ssrf detector Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化智能 SSRF 檢測器\n\n Args:\n ...]
n4[self.config = config or SSRFConfig...]
n5[self.smart_manager = UnifiedSmartDetectio...]
n6[logger.info('Smart SSRF Detector initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化智能 SSRF 檢測器\n\n Args:\n ...]
n4[self.config = config or SSRFConfig...]
n5[self.smart_manager = UnifiedSmartDetectio...]
n6[logger.info(&#39;Smart SSRF Detector initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
767. function function ssrf aiva func ssrf smart ssrf detector Function build internal finding
flowchart TB
n1([開始])
n2([結束])
n3['構建內部地址檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[return {'finding_id': new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建內部地址檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[return {&#39;finding_id&#39;: new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
768. function function ssrf aiva func ssrf smart ssrf detector Function build oast finding
flowchart TB
n1([開始])
n2([結束])
n3['構建 OAST 檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[callbacks_info = f'{len(events)&...]
n8[return {'finding_id': new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建 OAST 檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[from services.aiva_common.utils import new_id]
n7[callbacks_info = f&#39;{len(events)&...]
n8[return {&#39;finding_id&#39;: new_id...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
769. function function ssrf aiva func ssrf smart ssrf detector Function extract token
flowchart TB
n1([開始])
n2([結束])
n3['從載荷中提取 token']
n4[return payload]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從載荷中提取 token&#39;]
n4[return payload]
n1 --> n3
n3 --> n4
n4 --> n2
770. function function ssrf aiva func ssrf smart ssrf detector Function prioritize vectors
flowchart TB
n1([開始])
n2([結束])
n3['\n 優先級排序測試向量\n\n Args:\n ...]
n4{if not self.config.cloud_metad...}
n5[return vectors]
n6[]
n7[cloud_vectors = []]
n8[other_vectors = []]
n9{for vector in vectors}
n10[payload = str(vector.payload)....]
n11[is_cloud = any((endpoint in pay...]
n12{if is_cloud}
n13[cloud_vectors.append(vector)]
n14[other_vectors.append(vector)]
n15[]
n16[]
n17[logger.debug(f'Vector prioritization: ...]
n18[return cloud_vectors + other_vectors]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n9
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 優先級排序測試向量\n\n Args:\n ...]
n4{if not self.config.cloud_metad...}
n5[return vectors]
n6[]
n7[cloud_vectors = []]
n8[other_vectors = []]
n9{for vector in vectors}
n10[payload = str(vector.payload)....]
n11[is_cloud = any((endpoint in pay...]
n12{if is_cloud}
n13[cloud_vectors.append(vector)]
n14[other_vectors.append(vector)]
n15[]
n16[]
n17[logger.debug(f&#39;Vector prioritization: ...]
n18[return cloud_vectors + other_vectors]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n9
n16 --> n17
n17 --> n18
n18 --> n2
771. function function ssrf aiva func ssrf smart ssrf detector Function add error
flowchart TB
n1([開始])
n2([結束])
n3['添加錯誤']
n4[self.errors.append(error)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加錯誤&#39;]
n4[self.errors.append(error)]
n1 --> n3
n3 --> n4
n4 --> n2
772. function function ssrf aiva func ssrf smart ssrf detector Function add finding
flowchart TB
n1([開始])
n2([結束])
n3['添加發現的漏洞']
n4[self.findings.append(finding)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加發現的漏洞&#39;]
n4[self.findings.append(finding)]
n1 --> n3
n3 --> n4
n4 --> n2
773. function function ssrf aiva func ssrf smart ssrf detector Function add oast callbacks
flowchart TB
n1([開始])
n2([結束])
n3['添加 OAST 回調數量']
n4[self.oast_callbacks += count]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加 OAST 回調數量&#39;]
n4[self.oast_callbacks += count]
n1 --> n3
n3 --> n4
n4 --> n2
774. function function ssrf aiva func ssrf smart ssrf detector Function increment attempts
flowchart TB
n1([開始])
n2([結束])
n3['增加嘗試次數']
n4[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;增加嘗試次數&#39;]
n4[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n2
775. function function ssrf aiva func ssrf smart ssrf detector Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSmart SSRF Detector - 智能 SSRF 檢測器\n整合統一檢測管...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[import time]
n8[from typing import Any]
n9[import httpx]
n10[from services.aiva_common.schemas import FunctionT...]
n11[from services.aiva_common.utils import get_logger]
n12[from services.function.common.detection_config imp...]
n13[from services.function.common.unified_smart_detect...]
n14[from .internal_address_detector import InternalAdd...]
n15[from .oast_dispatcher import OastDispatcher, OastE...]
n16[from .param_semantics_analyzer import OAST_PLACEHO...]
n17[logger = get_logger(__name__)]
n18[class SSRFDetectionContext(...)]
n19[class SmartSSRFDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSmart SSRF Detector - 智能 SSRF 檢測器\n整合統一檢測管...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[import time]
n8[from typing import Any]
n9[import httpx]
n10[from services.aiva_common.schemas import FunctionT...]
n11[from services.aiva_common.utils import get_logger]
n12[from services.function.common.detection_config imp...]
n13[from services.function.common.unified_smart_detect...]
n14[from .internal_address_detector import InternalAdd...]
n15[from .oast_dispatcher import OastDispatcher, OastE...]
n16[from .param_semantics_analyzer import OAST_PLACEHO...]
n17[logger = get_logger(__name__)]
n18[class SSRFDetectionContext(...)]
n19[class SmartSSRFDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
776. function function ssrf aiva func ssrf worker Function build internal finding
flowchart TB
n1([開始])
n2([結束])
n3[severity = _severity_from_summa...]
n4[evidence = FindingEvidence(payl...]
n5[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[severity = _severity_from_summa...]
n4[evidence = FindingEvidence(payl...]
n5[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
777. function function ssrf aiva func ssrf worker Function build oast finding
flowchart TB
n1([開始])
n2([結束])
n3[summary = '; '.join(filter...]
n4[evidence = FindingEvidence(payl...]
n5[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[summary = &#39;; &#39;.join(filter...]
n4[evidence = FindingEvidence(payl...]
n5[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
778. function function ssrf aiva func ssrf worker Function extract token
flowchart TB
n1([開始])
n2([結束])
n3[return payload.split('/')...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return payload.split(&#39;/&#39;)...]
n1 --> n3
n3 --> n2
779. function function ssrf aiva func ssrf worker Function format request
flowchart TB
n1([開始])
n2([結束])
n3{if request is None}
n4[return '']
n5[]
n6[lines = [f'{request.method} ...]
n7{for (key, value) in request.headers.i...}
n8[lines.append(f'{key}: {val...]
n9[]
n10[body = request.content.deco...]
n11{if body}
n12[lines.append('')]
n13[lines.append(body[:512])]
n14[]
n15[return '\n'.join(lines)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if request is None}
n4[return &#39;&#39;]
n5[]
n6[lines = [f&#39;{request.method} ...]
n7{for (key, value) in request.headers.i...}
n8[lines.append(f&#39;{key}: {val...]
n9[]
n10[body = request.content.deco...]
n11{if body}
n12[lines.append(&#39;&#39;)]
n13[lines.append(body[:512])]
n14[]
n15[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
780. function function ssrf aiva func ssrf worker Function format response
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f'HTTP {response.st...]
n4{for (key, value) in response.headers....}
n5[lines.append(f'{key}: {val...]
n6[]
n7[snippet = response.text[:512]]
n8{if snippet}
n9[lines.append('')]
n10[lines.append(snippet)]
n11[]
n12[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f&#39;HTTP {response.st...]
n4{for (key, value) in response.headers....}
n5[lines.append(f&#39;{key}: {val...]
n6[]
n7[snippet = response.text[:512]]
n8{if snippet}
n9[lines.append(&#39;&#39;)]
n10[lines.append(snippet)]
n11[]
n12[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
781. function function ssrf aiva func ssrf worker Function safe elapsed
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4[elapsed = response.elapsed]
n5[]
n6[except RuntimeError]
n7[return None]
n8{if not elapsed}
n9[return None]
n10[]
n11[return elapsed.total_seconds()]
n1 --> n3
n3 --> n4
n3 --> n6
n4 --> n5
n5 --> n8
n6 --> n7
n7 --> n5
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4[elapsed = response.elapsed]
n5[]
n6[except RuntimeError]
n7[return None]
n8{if not elapsed}
n9[return None]
n10[]
n11[return elapsed.total_seconds()]
n1 --> n3
n3 --> n4
n3 --> n6
n4 --> n5
n5 --> n8
n6 --> n7
n7 --> n5
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
782. function function ssrf aiva func ssrf worker Function severity from summary
flowchart TB
n1([開始])
n2([結束])
n3[keywords = ['169.254.169.254'...]
n4{if any((keyword in summary for...}
n5[return Severity.HIGH]
n6[]
n7[return Severity.MEDIUM]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[keywords = [&#39;169.254.169.254&#39;...]
n4{if any((keyword in summary for...}
n5[return Severity.HIGH]
n6[]
n7[return Severity.MEDIUM]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
783. function function ssrf aiva func ssrf worker Function to details
flowchart TB
n1([開始])
n2([結束])
n3[details: dict[str, Any] = {'atte...]
n4{if self.errors}
n5[details['errors'] = self....]
n6[]
n7[return details]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[details: dict[str, Any] = {&#39;atte...]
n4{if self.errors}
n5[details[&#39;errors&#39;] = self....]
n6[]
n7[return details]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
784. function function ssrf aiva func ssrf worker Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass, field]
n5[import json]
n6[from typing import Any, Protocol, runtime_checkabl...]
n7[from urllib.parse import parse_qsl, urlparse, urlu...]
n8[import httpx]
n9[from services.aiva_common.enums import Confidence,...]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .internal_address_detector import InternalAdd...]
n14[from .oast_dispatcher import OastDispatcher, OastE...]
n15[from .param_semantics_analyzer import OAST_PLACEHO...]
n16[from .result_publisher import SsrfResultPublisher]
n17[logger = get_logger(__name__)]
n18[DEFAULT_TIMEOUT_SECONDS = 15.0]
n19[class SsrfTelemetry(...)]
n20[class TaskExecutionResult(...)]
n21[def run(...)]
n22[def _execute_task(...)]
n23[def process_task(...)]
n24[def _resolve_payload(...)]
n25[def _issue_request(...)]
n26[def _build_internal_finding(...)]
n27[def _build_oast_finding(...)]
n28[def _format_request(...)]
n29[def _format_response(...)]
n30[def _safe_elapsed(...)]
n31[def _severity_from_summary(...)]
n32[def _extract_token(...)]
n33[class OastDispatcherLike(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass, field]
n5[import json]
n6[from typing import Any, Protocol, runtime_checkabl...]
n7[from urllib.parse import parse_qsl, urlparse, urlu...]
n8[import httpx]
n9[from services.aiva_common.enums import Confidence,...]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .internal_address_detector import InternalAdd...]
n14[from .oast_dispatcher import OastDispatcher, OastE...]
n15[from .param_semantics_analyzer import OAST_PLACEHO...]
n16[from .result_publisher import SsrfResultPublisher]
n17[logger = get_logger(__name__)]
n18[DEFAULT_TIMEOUT_SECONDS = 15.0]
n19[class SsrfTelemetry(...)]
n20[class TaskExecutionResult(...)]
n21[def run(...)]
n22[def _execute_task(...)]
n23[def process_task(...)]
n24[def _resolve_payload(...)]
n25[def _issue_request(...)]
n26[def _build_internal_finding(...)]
n27[def _build_oast_finding(...)]
n28[def _format_request(...)]
n29[def _format_response(...)]
n30[def _safe_elapsed(...)]
n31[def _severity_from_summary(...)]
n32[def _extract_token(...)]
n33[class OastDispatcherLike(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
785. function function xss init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
786. function function xss aiva func xss init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
787. function function xss aiva func xss blind xss listener validator Function init
flowchart TB
n1([開始])
n2([結束])
n3{if store is None}
n4[base_url = os.getenv('OAST_SERV...]
n5[store = OastHttpCallbackStor...]
n6[]
n7[self._store = store]
n8[self._token: str | None = None]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n6
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if store is None}
n4[base_url = os.getenv(&#39;OAST_SERV...]
n5[store = OastHttpCallbackStor...]
n6[]
n7[self._store = store]
n8[self._token: str | None = None]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n6
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
788. function function xss aiva func xss blind xss listener validator Function resolve token
flowchart TB
n1([開始])
n2([結束])
n3{if payload_identifier in self....}
n4[return self._payload_tokens[payload_i...]
n5[]
n6[parsed = urlparse(payload_ide...]
n7{if parsed.path}
n8[token = parsed.path.rstrip('...]
n9[self._payload_tokens[payload_identifier] = token]
n10[return token]
n11[]
n12[return payload_identifier]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if payload_identifier in self....}
n4[return self._payload_tokens[payload_i...]
n5[]
n6[parsed = urlparse(payload_ide...]
n7{if parsed.path}
n8[token = parsed.path.rstrip(&#39;...]
n9[self._payload_tokens[payload_identifier] = token]
n10[return token]
n11[]
n12[return payload_identifier]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
789. function function xss aiva func xss blind xss listener validator Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Iterable]
n5[from dataclasses import dataclass]
n6[import json]
n7[import os]
n8[from typing import Any, Protocol, cast]
n9[from urllib.parse import urlparse]
n10[import httpx]
n11[from services.aiva_common.schemas import FunctionT...]
n12[from services.aiva_common.utils import new_id]
n13[class BlindXssEvent(...)]
n14[class BlindCallbackStore(...)]
n15[class _NullBlindCallbackStore(...)]
n16[class OastHttpCallbackStore(...)]
n17[class BlindXssListenerValidator(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Iterable]
n5[from dataclasses import dataclass]
n6[import json]
n7[import os]
n8[from typing import Any, Protocol, cast]
n9[from urllib.parse import urlparse]
n10[import httpx]
n11[from services.aiva_common.schemas import FunctionT...]
n12[from services.aiva_common.utils import new_id]
n13[class BlindXssEvent(...)]
n14[class BlindCallbackStore(...)]
n15[class _NullBlindCallbackStore(...)]
n16[class OastHttpCallbackStore(...)]
n17[class BlindXssListenerValidator(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
790. function function xss aiva func xss dom xss detector Function analyze
flowchart TB
n1([開始])
n2([結束])
n3['Return a DOM detection result when the paylo...]
n4{if not payload or not document}
n5[return None]
n6[]
n7[index = document.find(payloa...]
n8{if index == -1}
n9[return None]
n10[]
n11[window_start = max(0, index - 160)]
n12[window_end = min(len(document), i...]
n13[window = document[window_star...]
n14[lower_window = window.lower()]
n15{if '<script' in lower_wind...}
n16[snippet = window.strip()]
n17[return DomDetectionResult(payload=pay...]
n18[]
n19[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Return a DOM detection result when the paylo...]
n4{if not payload or not document}
n5[return None]
n6[]
n7[index = document.find(payloa...]
n8{if index == -1}
n9[return None]
n10[]
n11[window_start = max(0, index - 160)]
n12[window_end = min(len(document), i...]
n13[window = document[window_star...]
n14[lower_window = window.lower()]
n15{if &#39;&lt;script&#39; in lower_wind...}
n16[snippet = window.strip()]
n17[return DomDetectionResult(payload=pay...]
n18[]
n19[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
791. function function xss aiva func xss dom xss detector Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[class DomDetectionResult(...)]
n6[class DomXssDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[class DomDetectionResult(...)]
n6[class DomXssDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
792. function function xss aiva func xss payload generator Function generate advanced payloads
flowchart TB
n1([開始])
n2([結束])
n3['Generate advanced XSS payloads for testing.&...]
n4[return self.generate(payload_sets=['a...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Generate advanced XSS payloads for testing.&...]
n4[return self.generate(payload_sets=[&#39;a...]
n1 --> n3
n3 --> n4
n4 --> n2
793. function function xss aiva func xss payload generator Function generate all payloads
flowchart TB
n1([開始])
n2([結束])
n3['Generate all available XSS payloads.&...]
n4[return self.generate(payload_sets=['b...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Generate all available XSS payloads.&...]
n4[return self.generate(payload_sets=[&#39;b...]
n1 --> n3
n3 --> n4
n4 --> n2
794. function function xss aiva func xss payload generator Function generate basic payloads
flowchart TB
n1([開始])
n2([結束])
n3['Generate basic XSS payloads for testing.&...]
n4[return self.generate(payload_sets=['b...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Generate basic XSS payloads for testing.&...]
n4[return self.generate(payload_sets=[&#39;b...]
n1 --> n3
n3 --> n4
n4 --> n2
795. function function xss aiva func xss payload generator Function generate
flowchart TB
n1([開始])
n2([結束])
n3['Return a de-duplicated payload list preservi...]
n4[ordered: OrderedDict[str, None] = OrderedDict(...]
n5{for name in payload_sets or (...}
n6{for payload in self._PAYLOAD_SET...}
n7[ordered.setdefault(payload, None)]
n8[]
n9[]
n10{for payload in custom_payloads o...}
n11{if payload}
n12[ordered.setdefault(payload, None)]
n13[]
n14[]
n15{if blind_payload}
n16[ordered.setdefault(blind_payload, None)]
n17[]
n18[return list(ordered.keys())]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n5
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n10
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Return a de-duplicated payload list preservi...]
n4[ordered: OrderedDict[str, None] = OrderedDict(...]
n5{for name in payload_sets or (...}
n6{for payload in self._PAYLOAD_SET...}
n7[ordered.setdefault(payload, None)]
n8[]
n9[]
n10{for payload in custom_payloads o...}
n11{if payload}
n12[ordered.setdefault(payload, None)]
n13[]
n14[]
n15{if blind_payload}
n16[ordered.setdefault(blind_payload, None)]
n17[]
n18[return list(ordered.keys())]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n5
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n10
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
796. function function xss aiva func xss payload generator Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections import OrderedDict]
n5[from collections.abc import Iterable, Sequence]
n6[class XssPayloadGenerator(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections import OrderedDict]
n5[from collections.abc import Iterable, Sequence]
n6[class XssPayloadGenerator(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
797. function function xss aiva func xss result publisher Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or os.gete...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or os.gete...]
n1 --> n3
n3 --> n4
n4 --> n2
798. function function xss aiva func xss result publisher Function worker id
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
799. function function xss aiva func xss result publisher Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[import os]
n6[from typing import Any]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class XssResultPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[import os]
n6[from typing import Any]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class XssResultPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
800. function function xss aiva func xss schemas Function record blind callback
flowchart TB
n1([開始])
n2([結束])
n3['記錄盲 XSS 回調']
n4[self.blind_callbacks += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄盲 XSS 回調&#39;]
n4[self.blind_callbacks += 1]
n1 --> n3
n3 --> n4
n4 --> n2
801. function function xss aiva func xss schemas Function record context
flowchart TB
n1([開始])
n2([結束])
n3['記錄測試的上下文']
n4{if context not in self.context...}
n5[self.contexts_tested.append(context)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄測試的上下文&#39;]
n4{if context not in self.context...}
n5[self.contexts_tested.append(context)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
802. function function xss aiva func xss schemas Function record dom escalation
flowchart TB
n1([開始])
n2([結束])
n3['記錄 DOM XSS 升級']
n4[self.dom_escalations += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 DOM XSS 升級&#39;]
n4[self.dom_escalations += 1]
n1 --> n3
n3 --> n4
n4 --> n2
803. function function xss aiva func xss schemas Function record reflection
flowchart TB
n1([開始])
n2([結束])
n3['記錄反射發現']
n4[self.reflections += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄反射發現&#39;]
n4[self.reflections += 1]
n1 --> n3
n3 --> n4
n4 --> n2
804. function function xss aiva func xss schemas Function record stored xss
flowchart TB
n1([開始])
n2([結束])
n3['記錄存儲型 XSS']
n4[self.stored_xss_found += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄存儲型 XSS&#39;]
n4[self.stored_xss_found += 1]
n1 --> n3
n3 --> n4
n4 --> n2
805. function function xss aiva func xss schemas Function to detail
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細字符串']
n4[prefix = f'[{self.vector}]&...]
n5[return f'{prefix} {self.payloa...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細字符串&#39;]
n4[prefix = f&#39;[{self.vector}]&...]
n5[return f&#39;{prefix} {self.payloa...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
806. function function xss aiva func xss schemas Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式']
n4[details = super().to_details(f...]
n5[details.update({'reflections&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式&#39;]
n4[details = super().to_details(f...]
n5[details.update({&#39;reflections&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
807. function function xss aiva func xss schemas Function validate method
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 方法']
n4[allowed = {'GET', &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f'Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 方法&#39;]
n4[allowed = {&#39;GET&#39;, &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f&#39;Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
808. function function xss aiva func xss schemas Function validate sink type
flowchart TB
n1([開始])
n2([結束])
n3['驗證 sink 類型']
n4[allowed = {'innerHTML', &...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid sink_type: ...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 sink 類型&#39;]
n4[allowed = {&#39;innerHTML&#39;, &...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid sink_type: ...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
809. function function xss aiva func xss schemas Function validate source type
flowchart TB
n1([開始])
n2([結束])
n3['驗證 source 類型']
n4[allowed = {'location.hash', ...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid source_type: &...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 source 類型&#39;]
n4[allowed = {&#39;location.hash&#39;, ...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid source_type: &...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
810. function function xss aiva func xss schemas Function validate status
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 狀態碼']
n4{if not 100 <= v < 600}
n5[raise ValueError(f'Invalid HTTP status co...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 狀態碼&#39;]
n4{if not 100 &lt;= v &lt; 600}
n5[raise ValueError(f&#39;Invalid HTTP status co...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
811. function function xss aiva func xss schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nXSS 模組專用數據合約\n定義 XSS 檢測相關的所有數據結構,基於 Pydant...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingPa...]
n8[class XssDetectionResult(...)]
n9[class XssTelemetry(...)]
n10[class DomDetectionResult(...)]
n11[class StoredXssResult(...)]
n12[class XssExecutionError(...)]
n13[class TaskExecutionResult(...)]
n14[XssExecutionTelemetry = XssTelemetry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nXSS 模組專用數據合約\n定義 XSS 檢測相關的所有數據結構,基於 Pydant...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingPa...]
n8[class XssDetectionResult(...)]
n9[class XssTelemetry(...)]
n10[class DomDetectionResult(...)]
n11[class StoredXssResult(...)]
n12[class XssExecutionError(...)]
n13[class TaskExecutionResult(...)]
n14[XssExecutionTelemetry = XssTelemetry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
812. function function xss aiva func xss stored detector Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n4[self._timeout = timeout]
n5[self._client = client]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n4[self._timeout = timeout]
n5[self._client = client]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
813. function function xss aiva func xss stored detector Function fallback view url
flowchart TB
n1([開始])
n2([結束])
n3[parsed = urlparse(str(self._t...]
n4[return urlunparse(parsed._replace(que...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[parsed = urlparse(str(self._t...]
n4[return urlunparse(parsed._replace(que...]
n1 --> n3
n3 --> n4
n4 --> n2
814. function function xss aiva func xss stored detector Function inject query
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parsed = urlparse(url)]
n7[query_items: dict[str, str] = {}]
n8{if parsed.query}
n9{for pair in parsed.query.spli...}
n10{if not pair}
n11[continue]
n12[]
n13{if '=' in pair}
n14[(key, val) = pair.split('=&...]
n15[query_items[key] = val]
n16[query_items[pair] = '']
n17[]
n18[]
n19[]
n20[query_items[parameter] = value]
n21[parts = list(parsed)]
n22[from urllib.parse import urlencode]
n23[parts[4] = urlencode(query_item...]
n24[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n19
n9 -->|Yes| n10
n9 -->|No| n18
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n17
n16 --> n17
n17 --> n9
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parsed = urlparse(url)]
n7[query_items: dict[str, str] = {}]
n8{if parsed.query}
n9{for pair in parsed.query.spli...}
n10{if not pair}
n11[continue]
n12[]
n13{if &#39;=&#39; in pair}
n14[(key, val) = pair.split(&#39;=&&#...]
n15[query_items[key] = val]
n16[query_items[pair] = &#39;&#39;]
n17[]
n18[]
n19[]
n20[query_items[parameter] = value]
n21[parts = list(parsed)]
n22[from urllib.parse import urlencode]
n23[parts[4] = urlencode(query_item...]
n24[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n19
n9 -->|Yes| n10
n9 -->|No| n18
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n17
n16 --> n17
n17 --> n9
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
815. function function xss aiva func xss stored detector Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Iterable, Sequence]
n5[from dataclasses import dataclass]
n6[from urllib.parse import urlparse, urlunparse]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[class StoredXssResult(...)]
n10[class StoredXssDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Iterable, Sequence]
n5[from dataclasses import dataclass]
n6[from urllib.parse import urlparse, urlunparse]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[class StoredXssResult(...)]
n10[class StoredXssDetector(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
816. function function xss aiva func xss task queue Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._clock = clock or time.monoto...]
n4[self._condition = asyncio.Condition()]
n5[self._counter = itertools.count()]
n6[self._heap: list[_QueueEntry] = []]
n7[self._entries: dict[str, _QueueEntry] = {}]
n8[self._closed = False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._clock = clock or time.monoto...]
n4[self._condition = asyncio.Condition()]
n5[self._counter = itertools.count()]
n6[self._heap: list[_QueueEntry] = []]
n7[self._entries: dict[str, _QueueEntry] = {}]
n8[self._closed = False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
817. function function xss aiva func xss task queue Function len
flowchart TB
n1([開始])
n2([結束])
n3[return sum((1 for entry in self._entr...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return sum((1 for entry in self._entr...]
n1 --> n3
n3 --> n2
818. function function xss aiva func xss task queue Function discard invalid locked
flowchart TB
n1([開始])
n2([結束])
n3{while self._heap and (not se...}
n4[heapq.heappop(self._heap)]
n5[]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n3
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{while self._heap and (not se...}
n4[heapq.heappop(self._heap)]
n5[]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n3
n5 --> n2
819. function function xss aiva func xss task queue Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from collections.abc import Callable]
n6[from contextlib import suppress]
n7[from dataclasses import dataclass, field]
n8[import heapq]
n9[import itertools]
n10[import time]
n11[from services.aiva_common.schemas import FunctionT...]
n12[class QueuedTask(...)]
n13[class _QueueEntry(...)]
n14[class XssTaskQueue(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from collections.abc import Callable]
n6[from contextlib import suppress]
n7[from dataclasses import dataclass, field]
n8[import heapq]
n9[import itertools]
n10[import time]
n11[from services.aiva_common.schemas import FunctionT...]
n12[class QueuedTask(...)]
n13[class _QueueEntry(...)]
n14[class XssTaskQueue(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
820. function function xss aiva func xss traditional detector Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n4[self._timeout = timeout]
n5[self._client = client]
n6[self._retries = max(0, retries)]
n7[self._errors: list[XssExecutionError] = []]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n4[self._timeout = timeout]
n5[self._client = client]
n6[self._retries = max(0, retries)]
n7[self._errors: list[XssExecutionError] = []]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
821. function function xss aiva func xss traditional detector Function build request parts
flowchart TB
n1([開始])
n2([結束])
n3['Build request parts for httpx.AsyncClient.re...]
n4[target = self._task.target]
n5[method = (target.method or 'G...]
n6[location = (target.parameter_lo...]
n7[parameter = target.parameter]
n8[url = str(target.url)]
n9[headers = dict(target.headers ...]
n10[cookies = dict(target.cookies ...]
n11[data: dict[str, object] | None = None]
n12[json_data: dict[str, object] | None = None]
n13[content: bytes | None = None]
n14{if location == 'query' or (lo...}
n15[url = _inject_query(url, p...]
n16{if location == 'form'}
n17[form = copy.deepcopy(target...]
n18[data = _inject_mapping(form...]
n19{if location == 'json'}
n20[json_base = copy.deepcopy(target...]
n21[json_data = _inject_mapping(json...]
n22{if location == 'header' and pa...}
n23[headers[parameter] = payload]
n24{if location == 'cookie' and pa...}
n25[cookies[parameter] = payload]
n26{if location == 'body'}
n27[content = payload.encode('utf-...]
n28{if target.body}
n29[content = target.body.encode('...]
n30[]
n31[]
n32[]
n33[]
n34[]
n35[]
n36[]
n37[return (method, url, headers or None,...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n36
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n35
n19 -->|Yes| n20
n19 -->|No| n22
n20 --> n21
n21 --> n34
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n33
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n32
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n31
n28 -->|Yes| n29
n28 -->|No| n30
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Build request parts for httpx.AsyncClient.re...]
n4[target = self._task.target]
n5[method = (target.method or &#39;G...]
n6[location = (target.parameter_lo...]
n7[parameter = target.parameter]
n8[url = str(target.url)]
n9[headers = dict(target.headers ...]
n10[cookies = dict(target.cookies ...]
n11[data: dict[str, object] | None = None]
n12[json_data: dict[str, object] | None = None]
n13[content: bytes | None = None]
n14{if location == &#39;query&#39; or (lo...}
n15[url = _inject_query(url, p...]
n16{if location == &#39;form&#39;}
n17[form = copy.deepcopy(target...]
n18[data = _inject_mapping(form...]
n19{if location == &#39;json&#39;}
n20[json_base = copy.deepcopy(target...]
n21[json_data = _inject_mapping(json...]
n22{if location == &#39;header&#39; and pa...}
n23[headers[parameter] = payload]
n24{if location == &#39;cookie&#39; and pa...}
n25[cookies[parameter] = payload]
n26{if location == &#39;body&#39;}
n27[content = payload.encode(&#39;utf-...]
n28{if target.body}
n29[content = target.body.encode(&#39;...]
n30[]
n31[]
n32[]
n33[]
n34[]
n35[]
n36[]
n37[return (method, url, headers or None,...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n36
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n35
n19 -->|Yes| n20
n19 -->|No| n22
n20 --> n21
n21 --> n34
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n33
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n32
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n31
n28 -->|Yes| n29
n28 -->|No| n30
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n2
822. function function xss aiva func xss traditional detector Function inject mapping
flowchart TB
n1([開始])
n2([結束])
n3{if not mapping}
n4[return {parameter or 'xss_probe&#...]
n5[]
n6{if parameter and parameter in ...}
n7[mapping[parameter] = payload]
n8[return mapping]
n9[]
n10{if parameter and parameter not...}
n11[mapping[parameter] = payload]
n12[return mapping]
n13[]
n14{for key in list(mapping.keys())}
n15[mapping[key] = payload]
n16[]
n17[return mapping]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n14
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not mapping}
n4[return {parameter or &#39;xss_probe&#...]
n5[]
n6{if parameter and parameter in ...}
n7[mapping[parameter] = payload]
n8[return mapping]
n9[]
n10{if parameter and parameter not...}
n11[mapping[parameter] = payload]
n12[return mapping]
n13[]
n14{for key in list(mapping.keys())}
n15[mapping[key] = payload]
n16[]
n17[return mapping]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n14
n16 --> n17
n17 --> n2
823. function function xss aiva func xss traditional detector Function inject query
flowchart TB
n1([開始])
n2([結束])
n3[parsed = urlparse(url)]
n4[query_items: dict[str, str] = {}]
n5{if parsed.query}
n6{for pair in parsed.query.spli...}
n7{if not pair}
n8[continue]
n9[]
n10{if '=' in pair}
n11[(key, value) = pair.split('=&...]
n12[query_items[key] = value]
n13[query_items[pair] = '']
n14[]
n15[]
n16[]
n17{if parameter}
n18[query_items[parameter] = payload]
n19[query_items.setdefault('xss_probe&...]
n20[]
n21[new_query = urlencode(query_item...]
n22[parts = list(parsed)]
n23[parts[4] = new_query]
n24[return urlunparse(parts)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n16
n6 -->|Yes| n7
n6 -->|No| n15
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n14
n13 --> n14
n14 --> n6
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[parsed = urlparse(url)]
n4[query_items: dict[str, str] = {}]
n5{if parsed.query}
n6{for pair in parsed.query.spli...}
n7{if not pair}
n8[continue]
n9[]
n10{if &#39;=&#39; in pair}
n11[(key, value) = pair.split(&#39;=&...]
n12[query_items[key] = value]
n13[query_items[pair] = &#39;&#39;]
n14[]
n15[]
n16[]
n17{if parameter}
n18[query_items[parameter] = payload]
n19[query_items.setdefault(&#39;xss_probe&...]
n20[]
n21[new_query = urlencode(query_item...]
n22[parts = list(parsed)]
n23[parts[4] = new_query]
n24[return urlunparse(parts)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n16
n6 -->|Yes| n7
n6 -->|No| n15
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n14
n13 --> n14
n14 --> n6
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
824. function function xss aiva func xss traditional detector Function payload in response
flowchart TB
n1([開始])
n2([結束])
n3{if payload in body_text}
n4[return True]
n5[]
n6[decoded = unquote_plus(body_te...]
n7{if payload in decoded}
n8[return True]
n9[]
n10[html_decoded = unescape(body_text)]
n11[return payload in html_decoded]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if payload in body_text}
n4[return True]
n5[]
n6[decoded = unquote_plus(body_te...]
n7{if payload in decoded}
n8[return True]
n9[]
n10[html_decoded = unescape(body_text)]
n11[return payload in html_decoded]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
825. function function xss aiva func xss traditional detector Function errors
flowchart TB
n1([開始])
n2([結束])
n3[return list(self._errors)]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return list(self._errors)]
n1 --> n3
n3 --> n2
826. function function xss aiva func xss traditional detector Function to detail
flowchart TB
n1([開始])
n2([結束])
n3[prefix = f'[{self.vector}]&...]
n4[return f'{prefix} {self.payloa...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[prefix = f&#39;[{self.vector}]&...]
n4[return f&#39;{prefix} {self.payloa...]
n1 --> n3
n3 --> n4
n4 --> n2
827. function function xss aiva func xss traditional detector Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Sequence]
n5[import copy]
n6[from dataclasses import dataclass]
n7[from html import unescape]
n8[from urllib.parse import unquote_plus, urlencode, ...]
n9[import httpx]
n10[from services.aiva_common.schemas import FunctionT...]
n11[class XssDetectionResult(...)]
n12[class XssExecutionError(...)]
n13[class TraditionalXssDetector(...)]
n14[def _inject_mapping(...)]
n15[def _inject_query(...)]
n16[def _payload_in_response(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from collections.abc import Sequence]
n5[import copy]
n6[from dataclasses import dataclass]
n7[from html import unescape]
n8[from urllib.parse import unquote_plus, urlencode, ...]
n9[import httpx]
n10[from services.aiva_common.schemas import FunctionT...]
n11[class XssDetectionResult(...)]
n12[class XssExecutionError(...)]
n13[class TraditionalXssDetector(...)]
n14[def _inject_mapping(...)]
n15[def _inject_query(...)]
n16[def _payload_in_response(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
828. function function xss aiva func xss worker Function build blind finding
flowchart TB
n1([開始])
n2([結束])
n3[evidence = FindingEvidence(payl...]
n4[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[evidence = FindingEvidence(payl...]
n4[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n2
829. function function xss aiva func xss worker Function build finding
flowchart TB
n1([開始])
n2([結束])
n3[request = detection.request]
n4[request_url: HttpUrl = _validated_http_url(str(re...]
n5[evidence = FindingEvidence(payl...]
n6[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[request = detection.request]
n4[request_url: HttpUrl = _validated_http_url(str(re...]
n5[evidence = FindingEvidence(payl...]
n6[return FindingPayload(finding_id=new_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
830. function function xss aiva func xss worker Function build impact
flowchart TB
n1([開始])
n2([結束])
n3{if blind}
n4[return FindingImpact(description='Bli...]
n5[]
n6{if dom_result}
n7[description = 'Payload executed wi...]
n8[description = 'Payload reflected i...]
n9[]
n10[return FindingImpact(description=desc...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if blind}
n4[return FindingImpact(description=&#39;Bli...]
n5[]
n6{if dom_result}
n7[description = &#39;Payload executed wi...]
n8[description = &#39;Payload reflected i...]
n9[]
n10[return FindingImpact(description=desc...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n2
831. function function xss aiva func xss worker Function build payloads
flowchart TB
n1([開始])
n2([結束])
n3[config = task.test_config]
n4[payload_sets: Iterable[str] | None = config....]
n5[combined_custom: list[str] = []]
n6{if task.custom_payloads}
n7[combined_custom.extend(task.custom_payloads)]
n8[]
n9{if config.custom_payloads}
n10[combined_custom.extend(config.custom_payloads)]
n11[]
n12[payloads: list[str] = generator.generate(payl...]
n13[return payloads]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[config = task.test_config]
n4[payload_sets: Iterable[str] | None = config....]
n5[combined_custom: list[str] = []]
n6{if task.custom_payloads}
n7[combined_custom.extend(task.custom_payloads)]
n8[]
n9{if config.custom_payloads}
n10[combined_custom.extend(config.custom_payloads)]
n11[]
n12[payloads: list[str] = generator.generate(payl...]
n13[return payloads]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
832. function function xss aiva func xss worker Function build recommendation
flowchart TB
n1([開始])
n2([結束])
n3{if blind}
n4[fix = 'Audit server-side s...]
n5[fix = 'Apply context-aware...]
n6[]
n7[priority = 'Critical' if blind ...]
n8[return FindingRecommendation(fix=fix,...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if blind}
n4[fix = &#39;Audit server-side s...]
n5[fix = &#39;Apply context-aware...]
n6[]
n7[priority = &#39;Critical&#39; if blind ...]
n8[return FindingRecommendation(fix=fix,...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
833. function function xss aiva func xss worker Function format request
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f'{request.method} ...]
n4{for (key, value) in request.headers.i...}
n5[lines.append(f'{key}: {val...]
n6[]
n7[body = request.content.deco...]
n8{if body}
n9[lines.append('')]
n10[lines.append(body)]
n11[]
n12[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f&#39;{request.method} ...]
n4{for (key, value) in request.headers.i...}
n5[lines.append(f&#39;{key}: {val...]
n6[]
n7[body = request.content.deco...]
n8{if body}
n9[lines.append(&#39;&#39;)]
n10[lines.append(body)]
n11[]
n12[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
834. function function xss aiva func xss worker Function format response
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f'HTTP {detection.r...]
n4{for (key, value) in detection.respons...}
n5[lines.append(f'{key}: {val...]
n6[]
n7[snippet = detection.response_t...]
n8{if snippet}
n9[lines.append('')]
n10[lines.append(snippet)]
n11[]
n12{if dom_result}
n13[lines.append('')]
n14[lines.append('DOM Context:')]
n15[lines.append(dom_result.snippet)]
n16[]
n17[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f&#39;HTTP {detection.r...]
n4{for (key, value) in detection.respons...}
n5[lines.append(f&#39;{key}: {val...]
n6[]
n7[snippet = detection.response_t...]
n8{if snippet}
n9[lines.append(&#39;&#39;)]
n10[lines.append(snippet)]
n11[]
n12{if dom_result}
n13[lines.append(&#39;&#39;)]
n14[lines.append(&#39;DOM Context:&#39;)]
n15[lines.append(dom_result.snippet)]
n16[]
n17[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
835. function function xss aiva func xss worker Function inject query
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parts = list(urlparse(url))]
n7[query_pairs = dict(parse_qsl(parts...]
n8[query_pairs[parameter] = value]
n9[parts[4] = urlencode(query_pair...]
n10[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parts = list(urlparse(url))]
n7[query_pairs = dict(parse_qsl(parts...]
n8[query_pairs[parameter] = value]
n9[parts[4] = urlencode(query_pair...]
n10[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
836. function function xss aiva func xss worker Function proof text
flowchart TB
n1([開始])
n2([結束])
n3{if blind}
n4[return 'Blind callback received from ...]
n5[]
n6{if dom_result}
n7[return 'Payload observed within execu...]
n8[]
n9[return 'Payload reflected in HTTP res...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if blind}
n4[return &#39;Blind callback received from ...]
n5[]
n6{if dom_result}
n7[return &#39;Payload observed within execu...]
n8[]
n9[return &#39;Payload reflected in HTTP res...]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n2
837. function function xss aiva func xss worker Function validated http url
flowchart TB
n1([開始])
n2([結束])
n3[return _HTTP_URL_VALIDATOR.validate_p...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return _HTTP_URL_VALIDATOR.validate_p...]
n1 --> n3
n3 --> n2
838. function function xss aiva func xss worker Function to details
flowchart TB
n1([開始])
n2([結束])
n3[details: dict[str, Any] = {'find...]
n4{if self.errors}
n5[details['errors'] = self....]
n6[]
n7[return details]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[details: dict[str, Any] = {&#39;find...]
n4{if self.errors}
n5[details[&#39;errors&#39;] = self....]
n6[]
n7[return details]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
839. function function xss aiva func xss worker Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from collections.abc import Iterable]
n6[from dataclasses import dataclass, field]
n7[from typing import Any]
n8[from urllib.parse import parse_qsl, urlencode, url...]
n9[from pydantic import HttpUrl, TypeAdapter]
n10[from services.aiva_common.enums import Confidence,...]
n11[from services.aiva_common.mq import get_broker]
n12[from services.aiva_common.schemas import AivaMessa...]
n13[from services.aiva_common.utils import get_logger,...]
n14[from .blind_xss_listener_validator import BlindXss...]
n15[from .dom_xss_detector import DomDetectionResult, ...]
n16[from .payload_generator import XssPayloadGenerator]
n17[from .result_publisher import XssResultPublisher]
n18[from .stored_detector import StoredXssDetector, St...]
n19[from .task_queue import QueuedTask, XssTaskQueue]
n20[from .traditional_detector import TraditionalXssDe...]
n21[logger = get_logger(__name__)]
n22[_HTTP_URL_VALIDATOR = TypeAdapter(HttpUrl)]
n23[def _validated_http_url(...)]
n24[DEFAULT_TIMEOUT_SECONDS = 20.0]
n25[class XssExecutionTelemetry(...)]
n26[class TaskExecutionResult(...)]
n27[def run(...)]
n28[def _consume_queue(...)]
n29[def _execute_task(...)]
n30[def process_task(...)]
n31[def _build_payloads(...)]
n32[def _build_finding(...)]
n33[def _build_blind_finding(...)]
n34[def _build_impact(...)]
n35[def _build_recommendation(...)]
n36[def _proof_text(...)]
n37[def _format_request(...)]
n38[def _format_response(...)]
n39[def _inject_query(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from collections.abc import Iterable]
n6[from dataclasses import dataclass, field]
n7[from typing import Any]
n8[from urllib.parse import parse_qsl, urlencode, url...]
n9[from pydantic import HttpUrl, TypeAdapter]
n10[from services.aiva_common.enums import Confidence,...]
n11[from services.aiva_common.mq import get_broker]
n12[from services.aiva_common.schemas import AivaMessa...]
n13[from services.aiva_common.utils import get_logger,...]
n14[from .blind_xss_listener_validator import BlindXss...]
n15[from .dom_xss_detector import DomDetectionResult, ...]
n16[from .payload_generator import XssPayloadGenerator]
n17[from .result_publisher import XssResultPublisher]
n18[from .stored_detector import StoredXssDetector, St...]
n19[from .task_queue import QueuedTask, XssTaskQueue]
n20[from .traditional_detector import TraditionalXssDe...]
n21[logger = get_logger(__name__)]
n22[_HTTP_URL_VALIDATOR = TypeAdapter(HttpUrl)]
n23[def _validated_http_url(...)]
n24[DEFAULT_TIMEOUT_SECONDS = 20.0]
n25[class XssExecutionTelemetry(...)]
n26[class TaskExecutionResult(...)]
n27[def run(...)]
n28[def _consume_queue(...)]
n29[def _execute_task(...)]
n30[def process_task(...)]
n31[def _build_payloads(...)]
n32[def _build_finding(...)]
n33[def _build_blind_finding(...)]
n34[def _build_impact(...)]
n35[def _build_recommendation(...)]
n36[def _proof_text(...)]
n37[def _format_request(...)]
n38[def _format_response(...)]
n39[def _inject_query(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n2
840. function models Function validate function name
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {'xss', &#...]
n4{if v not in allowed}
n5[raise ValueError(f'function_name must be ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[allowed = {&#39;xss&#39;, &#...]
n4{if v not in allowed}
n5[raise ValueError(f&#39;function_name must be ...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
841. function models Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
842. function models Module
flowchart TB
n1([開始])
n2([結束])
n3['\nAIVA Function Models - 功能測試模組\n\n此文件包含與主動功...]
n4[from __future__ import annotations]
n5[from datetime import UTC, datetime]
n6[from typing import Any]
n7[from pydantic import BaseModel, Field, HttpUrl, fi...]
n8[from ..aiva_common.enums import Confidence, PostEx...]
n9[class FunctionTaskTarget(...)]
n10[class FunctionTaskContext(...)]
n11[class FunctionTaskTestConfig(...)]
n12[class FunctionTaskPayload(...)]
n13[class EnhancedFunctionTaskTarget(...)]
n14[class FunctionTelemetry(...)]
n15[class ExecutionError(...)]
n16[class FunctionExecutionResult(...)]
n17[class TestExecution(...)]
n18[class ExploitPayload(...)]
n19[class ExploitResult(...)]
n20[class PostExTestPayload(...)]
n21[class PostExResultPayload(...)]
n22[class APISchemaPayload(...)]
n23[class APITestCase(...)]
n24[class APISecurityTestPayload(...)]
n25[class OastEvent(...)]
n26[class OastProbe(...)]
n27[class BizLogicTestPayload(...)]
n28[class BizLogicResultPayload(...)]
n29[class AuthZCheckPayload(...)]
n30[class AuthZAnalysisPayload(...)]
n31[class AuthZResultPayload(...)]
n32[class SensitiveMatch(...)]
n33[class JavaScriptAnalysisResult(...)]
n34[__all__ = ['FunctionTaskTarget...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nAIVA Function Models - 功能測試模組\n\n此文件包含與主動功...]
n4[from __future__ import annotations]
n5[from datetime import UTC, datetime]
n6[from typing import Any]
n7[from pydantic import BaseModel, Field, HttpUrl, fi...]
n8[from ..aiva_common.enums import Confidence, PostEx...]
n9[class FunctionTaskTarget(...)]
n10[class FunctionTaskContext(...)]
n11[class FunctionTaskTestConfig(...)]
n12[class FunctionTaskPayload(...)]
n13[class EnhancedFunctionTaskTarget(...)]
n14[class FunctionTelemetry(...)]
n15[class ExecutionError(...)]
n16[class FunctionExecutionResult(...)]
n17[class TestExecution(...)]
n18[class ExploitPayload(...)]
n19[class ExploitResult(...)]
n20[class PostExTestPayload(...)]
n21[class PostExResultPayload(...)]
n22[class APISchemaPayload(...)]
n23[class APITestCase(...)]
n24[class APISecurityTestPayload(...)]
n25[class OastEvent(...)]
n26[class OastProbe(...)]
n27[class BizLogicTestPayload(...)]
n28[class BizLogicResultPayload(...)]
n29[class AuthZCheckPayload(...)]
n30[class AuthZAnalysisPayload(...)]
n31[class AuthZResultPayload(...)]
n32[class SensitiveMatch(...)]
n33[class JavaScriptAnalysisResult(...)]
n34[__all__ = [&#39;FunctionTaskTarget...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n2
843. function test schemas Function validate priority
flowchart TB
n1([開始])
n2([結束])
n3{if not 1 <= v <= 10}
n4[raise ValueError('priority must be betwee...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not 1 &lt;= v &lt;= 10}
n4[raise ValueError(&#39;priority must be betwee...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
844. function test schemas Function validate task id
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith('task_')}
n4[raise ValueError("task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not v.startswith(&#39;task_&#39;)}
n4[raise ValueError(&quot;task_id must start with &a...]
n5[]
n6[return v]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n2
845. function test schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nAIVA 功能測試模式定義\n\n包含功能測試、漏洞利用、測試結果等相關的數據模式。...]
n4[from __future__ import annotations]
n5[from datetime import UTC, datetime]
n6[from typing import Any]
n7[from services.aiva_common.enums import Confidence,...]
n8[from services.aiva_common.standards import CVSSv3M...]
n9[from pydantic import BaseModel, Field, HttpUrl, fi...]
n10[class FunctionTaskTarget(...)]
n11[class FunctionTaskContext(...)]
n12[class FunctionTaskTestConfig(...)]
n13[class FunctionTaskPayload(...)]
n14[class TestResult(...)]
n15[class ExploitConfiguration(...)]
n16[class ExploitResult(...)]
n17[class AuthZTestPayload(...)]
n18[class APISecurityTestPayload(...)]
n19[class PostExTestPayload(...)]
n20[class TestStatistics(...)]
n21[__all__ = ['FunctionTaskTarget...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nAIVA 功能測試模式定義\n\n包含功能測試、漏洞利用、測試結果等相關的數據模式。...]
n4[from __future__ import annotations]
n5[from datetime import UTC, datetime]
n6[from typing import Any]
n7[from services.aiva_common.enums import Confidence,...]
n8[from services.aiva_common.standards import CVSSv3M...]
n9[from pydantic import BaseModel, Field, HttpUrl, fi...]
n10[class FunctionTaskTarget(...)]
n11[class FunctionTaskContext(...)]
n12[class FunctionTaskTestConfig(...)]
n13[class FunctionTaskPayload(...)]
n14[class TestResult(...)]
n15[class ExploitConfiguration(...)]
n16[class ExploitResult(...)]
n17[class AuthZTestPayload(...)]
n18[class APISecurityTestPayload(...)]
n19[class PostExTestPayload(...)]
n20[class TestStatistics(...)]
n21[__all__ = [&#39;FunctionTaskTarget...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
846. integration aiva integration analysis compliance policy checker Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._policies: dict[str, dict[str, Any]]...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._policies: dict[str, dict[str, Any]]...]
n1 --> n3
n3 --> n2
847. integration aiva integration analysis compliance policy checker Function add custom policy
flowchart TB
n1([開始])
n2([結束])
n3['添加自定義合規政策']
n4[self._policies[policy_name] = policy_config]
n5[logger.info(f'Added custom compliance pol...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加自定義合規政策&#39;]
n4[self._policies[policy_name] = policy_config]
n5[logger.info(f&#39;Added custom compliance pol...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
848. integration aiva integration analysis compliance policy checker Function check compliance
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查漏洞發現是否符合指定的合規政策\n\n Args:...]
n4{if policy not in self._policies}
n5[return {'error': f&#...]
n6[]
n7[policy_config = self._policies[polic...]
n8[compliance_result = {'policy'...]
n9{for finding in findings}
n10[severity = finding.get('severit...]
n11[vuln_type = finding.get('vulnera...]
n12{if policy == 'owasp_top10' and...}
n13[compliance_result['critical_violations&am...]
n14[]
n15{if severity == 'critical'}
n16[compliance_result['critical_violations&am...]
n17{if severity == 'high'}
n18[compliance_result['high_violations&...]
n19{if severity == 'medium'}
n20[compliance_result['medium_violations&...]
n21[compliance_result['low_violations&...]
n22[]
n23[]
n24[]
n25[]
n26[total_violations = compliance_result['c...]
n27[max_possible_score = max(len(findings) * ...]
n28[compliance_result['compliance_score&&...]
n29{if compliance_result['critical...}
n30[compliance_result['recommendations&...]
n31[]
n32{if compliance_result['complian...}
n33[compliance_result['recommendations&...]
n34[]
n35[logger.info(f"Compliance check completed for...]
n36[return compliance_result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n25
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n24
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n23
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n9
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n34
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查漏洞發現是否符合指定的合規政策\n\n Args:...]
n4{if policy not in self._policies}
n5[return {&#39;error&#39;: f&#...]
n6[]
n7[policy_config = self._policies[polic...]
n8[compliance_result = {&#39;policy&#39...]
n9{for finding in findings}
n10[severity = finding.get(&#39;severit...]
n11[vuln_type = finding.get(&#39;vulnera...]
n12{if policy == &#39;owasp_top10&#39; and...}
n13[compliance_result[&#39;critical_violations&am...]
n14[]
n15{if severity == &#39;critical&#39;}
n16[compliance_result[&#39;critical_violations&am...]
n17{if severity == &#39;high&#39;}
n18[compliance_result[&#39;high_violations&&#...]
n19{if severity == &#39;medium&#39;}
n20[compliance_result[&#39;medium_violations&...]
n21[compliance_result[&#39;low_violations&...]
n22[]
n23[]
n24[]
n25[]
n26[total_violations = compliance_result[&#39;c...]
n27[max_possible_score = max(len(findings) * ...]
n28[compliance_result[&#39;compliance_score&&...]
n29{if compliance_result[&#39;critical...}
n30[compliance_result[&#39;recommendations&&#...]
n31[]
n32{if compliance_result[&#39;complian...}
n33[compliance_result[&#39;recommendations&&#...]
n34[]
n35[logger.info(f&quot;Compliance check completed for...]
n36[return compliance_result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n25
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n24
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n23
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n9
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n34
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n2
849. integration aiva integration analysis compliance policy checker Function get available policies
flowchart TB
n1([開始])
n2([結束])
n3['獲取可用的合規政策列表']
n4[return list(self._policies.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取可用的合規政策列表&#39;]
n4[return list(self._policies.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
850. integration aiva integration analysis risk assessment engine enhanced Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._risk_matrix = {'critical&#...]
n4[self._environment_multipliers = {'produc...]
n5[self._business_criticality_multipliers = {&#...]
n6[self._data_sensitivity_multipliers = {'h...]
n7[self._exploitability_multipliers = {'pro...]
n8[self._exposure_multipliers = {'internet_...]
n9[self._compliance_weights = {'pci-dss&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._risk_matrix = {&#39;critical&#...]
n4[self._environment_multipliers = {&#39;produc...]
n5[self._business_criticality_multipliers = {&#...]
n6[self._data_sensitivity_multipliers = {&#39;h...]
n7[self._exploitability_multipliers = {&#39;pro...]
n8[self._exposure_multipliers = {&#39;internet_...]
n9[self._compliance_weights = {&#39;pci-dss&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
851. integration aiva integration analysis risk assessment engine enhanced Function assess reputation risk
flowchart TB
n1([開始])
n2([結束])
n3['評估名譽風險']
n4{if business_criticality == 'cr...}
n5{if severity_counts['critical'...}
n6[return 'high']
n7{if severity_counts['high']...}
n8[return 'medium']
n9[]
n10[]
n11[]
n12[return 'low']
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n11
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;評估名譽風險&#39;]
n4{if business_criticality == &#39;cr...}
n5{if severity_counts[&#39;critical&#39;...}
n6[return &#39;high&#39;]
n7{if severity_counts[&#39;high&#39;]...}
n8[return &#39;medium&#39;]
n9[]
n10[]
n11[]
n12[return &#39;low&#39;]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n11
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n10
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
852. integration aiva integration analysis risk assessment engine enhanced Function calculate business impact factor
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算業務影響因子\n\n 基於資產價值和使用者基數評估...]
n4[impact_factor = 1.0]
n5{if asset_value > 0}
n6{if asset_value >= 10000000}
n7[impact_factor += 0.5]
n8{if asset_value >= 1000000}
n9[impact_factor += 0.3]
n10{if asset_value >= 100000}
n11[impact_factor += 0.2]
n12[]
n13[]
n14[]
n15[]
n16{if user_base > 0}
n17{if user_base >= 1000000}
n18[impact_factor += 0.4]
n19{if user_base >= 100000}
n20[impact_factor += 0.3]
n21{if user_base >= 10000}
n22[impact_factor += 0.2]
n23[]
n24[]
n25[]
n26[]
n27[return min(impact_factor, 2.5)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n15
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n14
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n26
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n25
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n24
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算業務影響因子\n\n 基於資產價值和使用者基數評估...]
n4[impact_factor = 1.0]
n5{if asset_value &gt; 0}
n6{if asset_value &gt;= 10000000}
n7[impact_factor += 0.5]
n8{if asset_value &gt;= 1000000}
n9[impact_factor += 0.3]
n10{if asset_value &gt;= 100000}
n11[impact_factor += 0.2]
n12[]
n13[]
n14[]
n15[]
n16{if user_base &gt; 0}
n17{if user_base &gt;= 1000000}
n18[impact_factor += 0.4]
n19{if user_base &gt;= 100000}
n20[impact_factor += 0.3]
n21{if user_base &gt;= 10000}
n22[impact_factor += 0.2]
n23[]
n24[]
n25[]
n26[]
n27[return min(impact_factor, 2.5)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n15
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n14
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n26
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n25
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n24
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n2
853. integration aiva integration analysis risk assessment engine enhanced Function calculate risk trend
flowchart TB
n1([開始])
n2([結束])
n3['計算風險趨勢(需要歷史資料)']
n4[new_findings = sum((1 for f in find...]
n5[total = len(findings)]
n6[trend = 'stable']
n7{if new_findings > total * 0.7}
n8[trend = 'increasing']
n9{if new_findings < total * 0.3}
n10[trend = 'decreasing']
n11[]
n12[]
n13[return {'trend': trend, &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算風險趨勢(需要歷史資料)&#39;]
n4[new_findings = sum((1 for f in find...]
n5[total = len(findings)]
n6[trend = &#39;stable&#39;]
n7{if new_findings &gt; total * 0.7}
n8[trend = &#39;increasing&#39;]
n9{if new_findings &lt; total * 0.3}
n10[trend = &#39;decreasing&#39;]
n11[]
n12[]
n13[return {&#39;trend&#39;: trend, &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
854. integration aiva integration analysis risk assessment engine enhanced Function determine risk level enhanced
flowchart TB
n1([開始])
n2([結束])
n3['\n 增強版風險等級判定\n\n 考慮業務重要性和環境因素\...]
n4{if avg_score >= 15}
n5[base_level = 'critical']
n6{if avg_score >= 10}
n7[base_level = 'high']
n8{if avg_score >= 5}
n9[base_level = 'medium']
n10[base_level = 'low']
n11[]
n12[]
n13[]
n14{if business_criticality == 'cr...}
n15[level_order = ['low', &...]
n16[current_index = level_order.index(ba...]
n17{if current_index < len(level_o...}
n18[return level_order[current_index + 1]]
n19[]
n20[]
n21[return base_level]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 增強版風險等級判定\n\n 考慮業務重要性和環境因素\...]
n4{if avg_score &gt;= 15}
n5[base_level = &#39;critical&#39;]
n6{if avg_score &gt;= 10}
n7[base_level = &#39;high&#39;]
n8{if avg_score &gt;= 5}
n9[base_level = &#39;medium&#39;]
n10[base_level = &#39;low&#39;]
n11[]
n12[]
n13[]
n14{if business_criticality == &#39;cr...}
n15[level_order = [&#39;low&#39;, &&#...]
n16[current_index = level_order.index(ba...]
n17{if current_index &lt; len(level_o...}
n18[return level_order[current_index + 1]]
n19[]
n20[]
n21[return base_level]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
855. integration aiva integration analysis risk assessment engine enhanced Function estimate business impact
flowchart TB
n1([開始])
n2([結束])
n3['估算業務影響']
n4[financial_impact = 0.0]
n5{if asset_value > 0}
n6[risk_percentage = severity_counts['cri...]
n7[financial_impact = asset_value * min(ri...]
n8[]
n9[affected_users = 0]
n10{if user_base > 0}
n11[exposure_rate = severity_counts['cri...]
n12[affected_users = int(user_base * min(...]
n13[]
n14[disruption_risk = 'low']
n15{if business_criticality == 'cr...}
n16{if severity_counts['critical'...}
n17[disruption_risk = 'high']
n18{if severity_counts['high']...}
n19[disruption_risk = 'medium']
n20[]
n21[]
n22[]
n23[return {'estimated_financial_impact&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n22
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;估算業務影響&#39;]
n4[financial_impact = 0.0]
n5{if asset_value &gt; 0}
n6[risk_percentage = severity_counts[&#39;cri...]
n7[financial_impact = asset_value * min(ri...]
n8[]
n9[affected_users = 0]
n10{if user_base &gt; 0}
n11[exposure_rate = severity_counts[&#39;cri...]
n12[affected_users = int(user_base * min(...]
n13[]
n14[disruption_risk = &#39;low&#39;]
n15{if business_criticality == &#39;cr...}
n16{if severity_counts[&#39;critical&#39;...}
n17[disruption_risk = &#39;high&#39;]
n18{if severity_counts[&#39;high&#39;]...}
n19[disruption_risk = &#39;medium&#39;]
n20[]
n21[]
n22[]
n23[return {&#39;estimated_financial_impact&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n22
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
856. integration aiva integration analysis risk assessment engine enhanced Function generate enhanced recommendations
flowchart TB
n1([開始])
n2([結束])
n3['生成增強的風險緩解建議']
n4[recommendations = []]
n5{if severity_counts['critical'...}
n6[recommendations.append(f"🚨 立即處理 {severi...]
n7[]
n8{if severity_counts['high']...}
n9[recommendations.append(f"⚠️ 優先處理 {sever...]
n10[]
n11{if business_criticality == 'cr...}
n12{if overall_risk_level in ['cri...}
n13[recommendations.append('💼 業務關鍵系統發現高風險漏洞,建...]
n14[recommendations.append('🔒 考慮暫時下線受影響功能直至漏洞...]
n15[]
n16[]
n17{if compliance_tags}
n18[compliance_str = ', '.join(co...]
n19[recommendations.append(f'📋 此資產受 {com...]
n20[]
n21{if len(priority_findings) > 0}
n22[top_vuln = priority_findings[0]]
n23[recommendations.append(f"🎯 最高優先級:{top_v...]
n24[]
n25{if overall_risk_level == 'crit...}
n26[recommendations.append('📞 建議立即通知相關利益相關者和管...]
n27[recommendations.append('🛡️ 考慮實施臨時緩解措施(WAF...]
n28[]
n29{if not recommendations}
n30[recommendations.append('✅ 繼續保持良好的安全實踐&...]
n31[]
n32[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n28
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n31
n31 --> n32
n32 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成增強的風險緩解建議&#39;]
n4[recommendations = []]
n5{if severity_counts[&#39;critical&#39;...}
n6[recommendations.append(f&quot;🚨 立即處理 {severi...]
n7[]
n8{if severity_counts[&#39;high&#39;]...}
n9[recommendations.append(f&quot;⚠️ 優先處理 {sever...]
n10[]
n11{if business_criticality == &#39;cr...}
n12{if overall_risk_level in [&#39;cri...}
n13[recommendations.append(&#39;💼 業務關鍵系統發現高風險漏洞,建...]
n14[recommendations.append(&#39;🔒 考慮暫時下線受影響功能直至漏洞...]
n15[]
n16[]
n17{if compliance_tags}
n18[compliance_str = &#39;, &#39;.join(co...]
n19[recommendations.append(f&#39;📋 此資產受 {com...]
n20[]
n21{if len(priority_findings) &gt; 0}
n22[top_vuln = priority_findings[0]]
n23[recommendations.append(f&quot;🎯 最高優先級:{top_v...]
n24[]
n25{if overall_risk_level == &#39;crit...}
n26[recommendations.append(&#39;📞 建議立即通知相關利益相關者和管...]
n27[recommendations.append(&#39;🛡️ 考慮實施臨時緩解措施(WAF...]
n28[]
n29{if not recommendations}
n30[recommendations.append(&#39;✅ 繼續保持良好的安全實踐&...]
n31[]
n32[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n16
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n28
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n31
n31 --> n32
n32 --> n2
857. integration aiva integration analysis risk assessment engine enhanced Function assess risk
flowchart TB
n1([開始])
n2([結束])
n3['\n 綜合風險評估(增強版)\n\n Args:\n ...]
n4{if not findings}
n5[return {'overall_risk_score'...]
n6[]
n7[environment = context.get('environ...]
n8[business_criticality = context.get('busin...]
n9[data_sensitivity = context.get('data_se...]
n10[asset_exposure = context.get('asset_e...]
n11[compliance_tags = context.get('complia...]
n12[asset_value = context.get('asset_v...]
n13[user_base = context.get('user_ba...]
n14[env_multiplier = self._environment_mu...]
n15[business_multiplier = self._business_criti...]
n16[data_multiplier = self._data_sensitivi...]
n17[exposure_multiplier = self._exposure_multi...]
n18[compliance_multiplier = 1.0]
n19{for tag in compliance_tags}
n20[tag_lower = tag.lower()]
n21{if tag_lower in self._complian...}
n22[compliance_multiplier = max(compliance_multi...]
n23[]
n24[]
n25[context_multiplier = env_multiplier * 0.3...]
n26[logger.info(f'Context multipliers - Env: ...]
n27[total_risk_score = 0.0]
n28[business_risk_score = 0.0]
n29[technical_risk_score = 0.0]
n30[priority_findings = []]
n31[severity_counts = {'critical'...]
n32{for finding in findings}
n33[severity = finding.get('severit...]
n34{if severity not in self._risk_...}
n35[severity = 'low']
n36[]
n37[base_score = self._risk_matrix[se...]
n38[technical_risk_score += base_score]
n39[exploitability = finding.get('exploit...]
n40[exploit_multiplier = self._exploitability...]
n41[adjusted_tech_score = base_score * exploit...]
n42[adjusted_business_score = adjusted_tech_score ...]
n43{if asset_value > 0 or user_bas...}
n44[impact_factor = self._calculate_busi...]
n45[adjusted_business_score *= impact_factor]
n46[]
n47[finding['calculated_technical_risk_score&...]
n48[finding['calculated_business_risk_score&a...]
n49[finding['context_multiplier'&...]
n50[total_risk_score += adjusted_business_score]
n51[business_risk_score += adjusted_business_score]
n52[severity_counts[severity] += 1]
n53{if severity in ['critical', &...}
n54[priority_findings.append(finding)]
n55[]
n56[]
n57[priority_findings.sort(key=lambda x: x.get(&&...]
n58[avg_business_risk = business_risk_score ...]
n59[overall_risk_level = self._determine_risk...]
n60[recommendations = self._generate_enhan...]
n61[business_impact = self._estimate_busin...]
n62[result = {'overall_risk_score...]
n63[logger.info(f'Risk assessment completed: ...]
n64[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n19
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n56
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 -->|Yes| n44
n43 -->|No| n46
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 -->|Yes| n54
n53 -->|No| n55
n54 --> n55
n55 --> n32
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 --> n64
n64 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 綜合風險評估(增強版)\n\n Args:\n ...]
n4{if not findings}
n5[return {&#39;overall_risk_score&#39;...]
n6[]
n7[environment = context.get(&#39;environ...]
n8[business_criticality = context.get(&#39;busin...]
n9[data_sensitivity = context.get(&#39;data_se...]
n10[asset_exposure = context.get(&#39;asset_e...]
n11[compliance_tags = context.get(&#39;complia...]
n12[asset_value = context.get(&#39;asset_v...]
n13[user_base = context.get(&#39;user_ba...]
n14[env_multiplier = self._environment_mu...]
n15[business_multiplier = self._business_criti...]
n16[data_multiplier = self._data_sensitivi...]
n17[exposure_multiplier = self._exposure_multi...]
n18[compliance_multiplier = 1.0]
n19{for tag in compliance_tags}
n20[tag_lower = tag.lower()]
n21{if tag_lower in self._complian...}
n22[compliance_multiplier = max(compliance_multi...]
n23[]
n24[]
n25[context_multiplier = env_multiplier * 0.3...]
n26[logger.info(f&#39;Context multipliers - Env: ...]
n27[total_risk_score = 0.0]
n28[business_risk_score = 0.0]
n29[technical_risk_score = 0.0]
n30[priority_findings = []]
n31[severity_counts = {&#39;critical&#39...]
n32{for finding in findings}
n33[severity = finding.get(&#39;severit...]
n34{if severity not in self._risk_...}
n35[severity = &#39;low&#39;]
n36[]
n37[base_score = self._risk_matrix[se...]
n38[technical_risk_score += base_score]
n39[exploitability = finding.get(&#39;exploit...]
n40[exploit_multiplier = self._exploitability...]
n41[adjusted_tech_score = base_score * exploit...]
n42[adjusted_business_score = adjusted_tech_score ...]
n43{if asset_value &gt; 0 or user_bas...}
n44[impact_factor = self._calculate_busi...]
n45[adjusted_business_score *= impact_factor]
n46[]
n47[finding[&#39;calculated_technical_risk_score&...]
n48[finding[&#39;calculated_business_risk_score&a...]
n49[finding[&#39;context_multiplier&#39;&...]
n50[total_risk_score += adjusted_business_score]
n51[business_risk_score += adjusted_business_score]
n52[severity_counts[severity] += 1]
n53{if severity in [&#39;critical&#39;, &...}
n54[priority_findings.append(finding)]
n55[]
n56[]
n57[priority_findings.sort(key=lambda x: x.get(&&...]
n58[avg_business_risk = business_risk_score ...]
n59[overall_risk_level = self._determine_risk...]
n60[recommendations = self._generate_enhan...]
n61[business_impact = self._estimate_busin...]
n62[result = {&#39;overall_risk_score...]
n63[logger.info(f&#39;Risk assessment completed: ...]
n64[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n19
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n56
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 -->|Yes| n44
n43 -->|No| n46
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 -->|Yes| n54
n53 -->|No| n55
n54 --> n55
n55 --> n32
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 --> n64
n64 --> n2
858. integration aiva integration analysis risk assessment engine enhanced Function compare risk trends
flowchart TB
n1([開始])
n2([結束])
n3['比較風險趨勢變化']
n4[current_score = current_assessment.g...]
n5[previous_score = previous_assessment....]
n6[score_change = current_score - prev...]
n7[trend = 'stable']
n8{if score_change > 5}
n9[trend = 'increasing']
n10{if score_change < -5}
n11[trend = 'decreasing']
n12[]
n13[]
n14[return {'current_score': cur...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;比較風險趨勢變化&#39;]
n4[current_score = current_assessment.g...]
n5[previous_score = previous_assessment....]
n6[score_change = current_score - prev...]
n7[trend = &#39;stable&#39;]
n8{if score_change &gt; 5}
n9[trend = &#39;increasing&#39;]
n10{if score_change &lt; -5}
n11[trend = &#39;decreasing&#39;]
n12[]
n13[]
n14[return {&#39;current_score&#39;: cur...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
859. integration aiva integration analysis risk assessment engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._risk_matrix = {'critical&#...]
n4[self._environment_multipliers = {'produc...]
n5[self._business_criticality_multipliers = {&#...]
n6[self._data_sensitivity_multipliers = {'h...]
n7[self._exploitability_multipliers = {'pro...]
n8[self._exposure_multipliers = {'internet_...]
n9[self._compliance_weights = {'pci-dss&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._risk_matrix = {&#39;critical&#...]
n4[self._environment_multipliers = {&#39;produc...]
n5[self._business_criticality_multipliers = {&#...]
n6[self._data_sensitivity_multipliers = {&#39;h...]
n7[self._exploitability_multipliers = {&#39;pro...]
n8[self._exposure_multipliers = {&#39;internet_...]
n9[self._compliance_weights = {&#39;pci-dss&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
860. integration aiva integration analysis risk assessment engine Function calculate business impact factor
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算業務影響因子(基於資產價值和使用者基數)\n\n ...]
n4[impact_factor = 1.0]
n5{if asset_value > 0}
n6[value_factor = min(1.0 + asset_valu...]
n7[impact_factor *= value_factor]
n8[]
n9{if user_base > 0}
n10[import math]
n11[user_factor = min(1.0 + math.log10...]
n12[impact_factor *= user_factor]
n13[]
n14[return min(impact_factor, 3.0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算業務影響因子(基於資產價值和使用者基數)\n\n ...]
n4[impact_factor = 1.0]
n5{if asset_value &gt; 0}
n6[value_factor = min(1.0 + asset_valu...]
n7[impact_factor *= value_factor]
n8[]
n9{if user_base &gt; 0}
n10[import math]
n11[user_factor = min(1.0 + math.log10...]
n12[impact_factor *= user_factor]
n13[]
n14[return min(impact_factor, 3.0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
861. integration aiva integration analysis risk assessment engine Function calculate risk trend
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算風險趨勢\n\n Args:\n ...]
n4{if not findings}
n5[return {'trend': ...]
n6[]
n7[risk_distribution = {'critical&#...]
n8[total_age_days = 0]
n9{for finding in findings}
n10[severity = finding.get('severit...]
n11{if severity in risk_distribution}
n12[risk_distribution[severity] += 1]
n13[]
n14[created_at = finding.get('created...]
n15{if created_at}
n16[total_age_days += 0]
n17[]
n18[]
n19[return {'trend': ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n18
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n9
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算風險趨勢\n\n Args:\n ...]
n4{if not findings}
n5[return {&#39;trend&#39;: &#3...]
n6[]
n7[risk_distribution = {&#39;critical&#...]
n8[total_age_days = 0]
n9{for finding in findings}
n10[severity = finding.get(&#39;severit...]
n11{if severity in risk_distribution}
n12[risk_distribution[severity] += 1]
n13[]
n14[created_at = finding.get(&#39;created...]
n15{if created_at}
n16[total_age_days += 0]
n17[]
n18[]
n19[return {&#39;trend&#39;: &#3...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n18
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n9
n18 --> n19
n19 --> n2
862. integration aiva integration analysis risk assessment engine Function determine risk level enhanced
flowchart TB
n1([開始])
n2([結束])
n3['\n 增強版風險等級判定(考慮業務重要性和環境)\n\n A...]
n4{if avg_risk_score >= 15}
n5[base_level = 'critical']
n6{if avg_risk_score >= 8}
n7[base_level = 'high']
n8{if avg_risk_score >= 3}
n9[base_level = 'medium']
n10[base_level = 'low']
n11[]
n12[]
n13[]
n14{if business_criticality == 'cr...}
n15{if base_level == 'high'}
n16[base_level = 'critical']
n17{if base_level == 'medium'}
n18[base_level = 'high']
n19[]
n20[]
n21[]
n22{if environment == 'production'...}
n23[base_level = 'high']
n24[]
n25[logger.debug(f'Enhanced risk level: {...]
n26[return base_level]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n21
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n20
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 增強版風險等級判定(考慮業務重要性和環境)\n\n A...]
n4{if avg_risk_score &gt;= 15}
n5[base_level = &#39;critical&#39;]
n6{if avg_risk_score &gt;= 8}
n7[base_level = &#39;high&#39;]
n8{if avg_risk_score &gt;= 3}
n9[base_level = &#39;medium&#39;]
n10[base_level = &#39;low&#39;]
n11[]
n12[]
n13[]
n14{if business_criticality == &#39;cr...}
n15{if base_level == &#39;high&#39;}
n16[base_level = &#39;critical&#39;]
n17{if base_level == &#39;medium&#39;}
n18[base_level = &#39;high&#39;]
n19[]
n20[]
n21[]
n22{if environment == &#39;production&#39;...}
n23[base_level = &#39;high&#39;]
n24[]
n25[logger.debug(f&#39;Enhanced risk level: {...]
n26[return base_level]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n21
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n20
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
863. integration aiva integration analysis risk assessment engine Function determine risk level
flowchart TB
n1([開始])
n2([結束])
n3['根據平均分數確定風險等級']
n4{if avg_score >= 8}
n5[return 'critical']
n6{if avg_score >= 5}
n7[return 'high']
n8{if avg_score >= 2}
n9[return 'medium']
n10[return 'low']
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;根據平均分數確定風險等級&#39;]
n4{if avg_score &gt;= 8}
n5[return &#39;critical&#39;]
n6{if avg_score &gt;= 5}
n7[return &#39;high&#39;]
n8{if avg_score &gt;= 2}
n9[return &#39;medium&#39;]
n10[return &#39;low&#39;]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
864. integration aiva integration analysis risk assessment engine Function estimate business impact
flowchart TB
n1([開始])
n2([結束])
n3['\n 估算業務影響\n\n Args:\n ...]
n4[base_loss = 0.0]
n5{if severity_counts['critical'...}
n6[base_loss += asset_value * 0.1 * severity_counts[&...]
n7[]
n8{if severity_counts['high']...}
n9[base_loss += asset_value * 0.03 * severity_counts[...]
n10[]
n11[affected_users = 0]
n12{if severity_counts['critical'...}
n13[affected_users = user_base]
n14{if severity_counts['medium'...}
n15[affected_users = int(user_base * 0.3)]
n16[]
n17[]
n18[disruption_risk = 'none']
n19{if severity_counts['critical'...}
n20[disruption_risk = 'high']
n21{if severity_counts['critical'...}
n22[disruption_risk = 'medium']
n23{if severity_counts['high']...}
n24[disruption_risk = 'low']
n25[]
n26[]
n27[]
n28[reputation_impact = 'none']
n29{if severity_counts['critical'...}
n30[reputation_impact = 'high']
n31{if severity_counts['high']...}
n32[reputation_impact = 'medium']
n33{if severity_counts['high']...}
n34[reputation_impact = 'low']
n35[]
n36[]
n37[]
n38[compliance_risk = 'unknown']
n39{if severity_counts['critical'...}
n40[compliance_risk = 'potential_violation...]
n41[]
n42[return {'estimated_financial_loss&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n27
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n26
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n37
n31 -->|Yes| n32
n31 -->|No| n33
n32 --> n36
n33 -->|Yes| n34
n33 -->|No| n35
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n41
n40 --> n41
n41 --> n42
n42 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 估算業務影響\n\n Args:\n ...]
n4[base_loss = 0.0]
n5{if severity_counts[&#39;critical&#39;...}
n6[base_loss += asset_value * 0.1 * severity_counts[&...]
n7[]
n8{if severity_counts[&#39;high&#39;]...}
n9[base_loss += asset_value * 0.03 * severity_counts[...]
n10[]
n11[affected_users = 0]
n12{if severity_counts[&#39;critical&#39;...}
n13[affected_users = user_base]
n14{if severity_counts[&#39;medium&#39;&#...}
n15[affected_users = int(user_base * 0.3)]
n16[]
n17[]
n18[disruption_risk = &#39;none&#39;]
n19{if severity_counts[&#39;critical&#39;...}
n20[disruption_risk = &#39;high&#39;]
n21{if severity_counts[&#39;critical&#39;...}
n22[disruption_risk = &#39;medium&#39;]
n23{if severity_counts[&#39;high&#39;]...}
n24[disruption_risk = &#39;low&#39;]
n25[]
n26[]
n27[]
n28[reputation_impact = &#39;none&#39;]
n29{if severity_counts[&#39;critical&#39;...}
n30[reputation_impact = &#39;high&#39;]
n31{if severity_counts[&#39;high&#39;]...}
n32[reputation_impact = &#39;medium&#39;]
n33{if severity_counts[&#39;high&#39;]...}
n34[reputation_impact = &#39;low&#39;]
n35[]
n36[]
n37[]
n38[compliance_risk = &#39;unknown&#39;]
n39{if severity_counts[&#39;critical&#39;...}
n40[compliance_risk = &#39;potential_violation...]
n41[]
n42[return {&#39;estimated_financial_loss&&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n27
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n26
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n31
n30 --> n37
n31 -->|Yes| n32
n31 -->|No| n33
n32 --> n36
n33 -->|Yes| n34
n33 -->|No| n35
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n41
n40 --> n41
n41 --> n42
n42 --> n2
865. integration aiva integration analysis risk assessment engine Function generate enhanced recommendations
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成增強的業務驅動建議\n\n Args:\n ...]
n4[recommendations = []]
n5{if severity_counts['critical'...}
n6[recommendations.append(f"【緊急】立即處理 {seve...]
n7{if business_criticality == 'cr...}
n8[recommendations.append('【緊急】建議啟動應急響應程序並通知...]
n9[]
n10[]
n11{if severity_counts['high']...}
n12[recommendations.append(f"【高優先級】24-48小時內處理 ...]
n13[]
n14{if overall_risk_level == 'crit...}
n15[recommendations.append('【業務影響】建議評估是否需要臨時下...]
n16[recommendations.append('【業務影響】建議啟動業務連續性計畫...]
n17[]
n18{if compliance_tags}
n19[compliance_str = ', '.join(co...]
n20[recommendations.append(f'【合規要求】此系統受 {...]
n21{if 'pci-dss' in [tag.lower...}
n22[recommendations.append('【PCI-DSS】嚴重及高風險漏洞...]
n23[]
n24{if 'gdpr' in [tag.lower(&...}
n25[recommendations.append('【GDPR】涉及個資的漏洞需在72...]
n26[]
n27[]
n28[vuln_types_seen = set()]
n29{for finding in priority_findings...}
n30[vuln_type = finding.get('vulnera...]
n31{if vuln_type not in vuln_types...}
n32[vuln_types_seen.add(vuln_type)]
n33[specific_rec = self._get_specific_r...]
n34{if specific_rec}
n35[recommendations.append(f'【技術建議】{spec...]
n36[]
n37[]
n38[]
n39{if severity_counts['medium'...}
n40[recommendations.append(f"【改善計畫】規劃修復 {se...]
n41[]
n42{if overall_risk_level == 'low'...}
n43[recommendations.append('【良好】繼續保持現有安全實踐&am...]
n44[]
n45{if environment == 'production'}
n46[recommendations.append('【預防】建議實施持續安全監控和定期...]
n47[]
n48[return recommendations if recommendat...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n27
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n38
n30 --> n31
n31 -->|Yes| n32
n31 -->|No| n37
n32 --> n33
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n36
n36 --> n37
n37 --> n29
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n41
n40 --> n41
n41 --> n42
n42 -->|Yes| n43
n42 -->|No| n44
n43 --> n44
n44 --> n45
n45 -->|Yes| n46
n45 -->|No| n47
n46 --> n47
n47 --> n48
n48 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成增強的業務驅動建議\n\n Args:\n ...]
n4[recommendations = []]
n5{if severity_counts[&#39;critical&#39;...}
n6[recommendations.append(f&quot;【緊急】立即處理 {seve...]
n7{if business_criticality == &#39;cr...}
n8[recommendations.append(&#39;【緊急】建議啟動應急響應程序並通知...]
n9[]
n10[]
n11{if severity_counts[&#39;high&#39;]...}
n12[recommendations.append(f&quot;【高優先級】24-48小時內處理 &#...]
n13[]
n14{if overall_risk_level == &#39;crit...}
n15[recommendations.append(&#39;【業務影響】建議評估是否需要臨時下...]
n16[recommendations.append(&#39;【業務影響】建議啟動業務連續性計畫...]
n17[]
n18{if compliance_tags}
n19[compliance_str = &#39;, &#39;.join(co...]
n20[recommendations.append(f&#39;【合規要求】此系統受 {...]
n21{if &#39;pci-dss&#39; in [tag.lower...}
n22[recommendations.append(&#39;【PCI-DSS】嚴重及高風險漏洞...]
n23[]
n24{if &#39;gdpr&#39; in [tag.lower(&...}
n25[recommendations.append(&#39;【GDPR】涉及個資的漏洞需在72...]
n26[]
n27[]
n28[vuln_types_seen = set()]
n29{for finding in priority_findings...}
n30[vuln_type = finding.get(&#39;vulnera...]
n31{if vuln_type not in vuln_types...}
n32[vuln_types_seen.add(vuln_type)]
n33[specific_rec = self._get_specific_r...]
n34{if specific_rec}
n35[recommendations.append(f&#39;【技術建議】{spec...]
n36[]
n37[]
n38[]
n39{if severity_counts[&#39;medium&#39;&#...}
n40[recommendations.append(f&quot;【改善計畫】規劃修復 {se...]
n41[]
n42{if overall_risk_level == &#39;low&#39;...}
n43[recommendations.append(&#39;【良好】繼續保持現有安全實踐&am...]
n44[]
n45{if environment == &#39;production&#39;}
n46[recommendations.append(&#39;【預防】建議實施持續安全監控和定期...]
n47[]
n48[return recommendations if recommendat...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n27
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n38
n30 --> n31
n31 -->|Yes| n32
n31 -->|No| n37
n32 --> n33
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n36
n36 --> n37
n37 --> n29
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n41
n40 --> n41
n41 --> n42
n42 -->|Yes| n43
n42 -->|No| n44
n43 --> n44
n44 --> n45
n45 -->|Yes| n46
n45 -->|No| n47
n46 --> n47
n47 --> n48
n48 --> n2
866. integration aiva integration analysis risk assessment engine Function generate impact summary
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成業務影響摘要\n\n Args:\n ...]
n4[summary_parts = []]
n5{if financial_loss > 0}
n6[summary_parts.append(f'潛在財務損失 ${fina...]
n7[]
n8{if affected_users > 0}
n9[summary_parts.append(f'可能影響 {affecte...]
n10[]
n11{if disruption_risk in ['high'...}
n12[summary_parts.append(f'業務中斷風險: {disr...]
n13[]
n14{if reputation_impact in ['high...}
n15[summary_parts.append(f'聲譽影響: {reputa...]
n16[]
n17[return ';'.join(summary_parts...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成業務影響摘要\n\n Args:\n ...]
n4[summary_parts = []]
n5{if financial_loss &gt; 0}
n6[summary_parts.append(f&#39;潛在財務損失 ${fina...]
n7[]
n8{if affected_users &gt; 0}
n9[summary_parts.append(f&#39;可能影響 {affecte...]
n10[]
n11{if disruption_risk in [&#39;high&#39;...}
n12[summary_parts.append(f&#39;業務中斷風險: {disr...]
n13[]
n14{if reputation_impact in [&#39;high...}
n15[summary_parts.append(f&#39;聲譽影響: {reputa...]
n16[]
n17[return &#39;;&#39;.join(summary_parts...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n2
867. integration aiva integration analysis risk assessment engine Function generate recommendations
flowchart TB
n1([開始])
n2([結束])
n3['生成風險緩解建議']
n4[recommendations = []]
n5{if severity_counts['critical'...}
n6[recommendations.append(f"立即處理 {severity...]
n7[]
n8{if severity_counts['high']...}
n9[recommendations.append(f"優先處理 {severity...]
n10[]
n11{if risk_level in ['critical',...}
n12[recommendations.append('建議考慮暫時下線相關功能直至漏洞修...]
n13[]
n14{if risk_level == 'critical'}
n15[recommendations.append('建議啟動緊急響應程序&...]
n16[recommendations.append('建議進行額外的安全加固措施&...]
n17[]
n18{if not recommendations}
n19[recommendations.append('繼續保持良好的安全實踐&&...]
n20[]
n21[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成風險緩解建議&#39;]
n4[recommendations = []]
n5{if severity_counts[&#39;critical&#39;...}
n6[recommendations.append(f&quot;立即處理 {severity...]
n7[]
n8{if severity_counts[&#39;high&#39;]...}
n9[recommendations.append(f&quot;優先處理 {severity...]
n10[]
n11{if risk_level in [&#39;critical&#39;,...}
n12[recommendations.append(&#39;建議考慮暫時下線相關功能直至漏洞修...]
n13[]
n14{if risk_level == &#39;critical&#39;}
n15[recommendations.append(&#39;建議啟動緊急響應程序&&#...]
n16[recommendations.append(&#39;建議進行額外的安全加固措施&...]
n17[]
n18{if not recommendations}
n19[recommendations.append(&#39;繼續保持良好的安全實踐&&...]
n20[]
n21[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n2
868. integration aiva integration analysis risk assessment engine Function get specific recommendation
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據漏洞類型提供具體技術建議\n\n Args:\n ...]
n4[recommendations_map = {'sql_injection&am...]
n5[return recommendations_map.get(vuln_t...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據漏洞類型提供具體技術建議\n\n Args:\n ...]
n4[recommendations_map = {&#39;sql_injection&am...]
n5[return recommendations_map.get(vuln_t...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
869. integration aiva integration analysis risk assessment engine Function assess risk
flowchart TB
n1([開始])
n2([結束])
n3['\n 綜合風險評估(增強版)\n\n Args:\n ...]
n4{if not findings}
n5[return {'overall_risk_score'...]
n6[]
n7[environment = context.get('environ...]
n8[business_criticality = context.get('busin...]
n9[data_sensitivity = context.get('data_se...]
n10[asset_exposure = context.get('asset_e...]
n11[compliance_tags = context.get('complia...]
n12[asset_value = context.get('asset_v...]
n13[user_base = context.get('user_ba...]
n14[env_multiplier = self._environment_mu...]
n15[business_multiplier = self._business_criti...]
n16[data_multiplier = self._data_sensitivi...]
n17[exposure_multiplier = self._exposure_multi...]
n18[compliance_multiplier = 1.0]
n19{for tag in compliance_tags}
n20[tag_lower = tag.lower()]
n21{if tag_lower in self._complian...}
n22[compliance_multiplier = max(compliance_multi...]
n23[]
n24[]
n25[context_multiplier = env_multiplier * 0.3...]
n26[logger.info(f'Context multipliers - Env: ...]
n27[total_risk_score = 0.0]
n28[business_risk_score = 0.0]
n29[technical_risk_score = 0.0]
n30[priority_findings = []]
n31[severity_counts = {'critical'...]
n32{for finding in findings}
n33[severity = finding.get('severit...]
n34{if severity not in self._risk_...}
n35[severity = 'low']
n36[]
n37[base_score = self._risk_matrix[se...]
n38[technical_risk_score += base_score]
n39[exploitability = finding.get('exploit...]
n40[exploit_multiplier = self._exploitability...]
n41[adjusted_tech_score = base_score * exploit...]
n42[adjusted_business_score = adjusted_tech_score ...]
n43{if asset_value > 0 or user_bas...}
n44[impact_factor = self._calculate_busi...]
n45[adjusted_business_score *= impact_factor]
n46[]
n47[finding['calculated_technical_risk_score&...]
n48[finding['calculated_business_risk_score&a...]
n49[finding['context_multiplier'&...]
n50[total_risk_score += adjusted_business_score]
n51[business_risk_score += adjusted_business_score]
n52[severity_counts[severity] += 1]
n53{if severity in ['critical', &...}
n54[priority_findings.append(finding)]
n55[]
n56[]
n57[priority_findings.sort(key=lambda x: x.get(&&...]
n58[avg_business_risk = business_risk_score ...]
n59[overall_risk_level = self._determine_risk...]
n60[recommendations = self._generate_enhan...]
n61[business_impact = self._estimate_busin...]
n62[result = {'overall_risk_score...]
n63[logger.info(f'Risk assessment completed: ...]
n64[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n19
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n56
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 -->|Yes| n44
n43 -->|No| n46
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 -->|Yes| n54
n53 -->|No| n55
n54 --> n55
n55 --> n32
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 --> n64
n64 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 綜合風險評估(增強版)\n\n Args:\n ...]
n4{if not findings}
n5[return {&#39;overall_risk_score&#39;...]
n6[]
n7[environment = context.get(&#39;environ...]
n8[business_criticality = context.get(&#39;busin...]
n9[data_sensitivity = context.get(&#39;data_se...]
n10[asset_exposure = context.get(&#39;asset_e...]
n11[compliance_tags = context.get(&#39;complia...]
n12[asset_value = context.get(&#39;asset_v...]
n13[user_base = context.get(&#39;user_ba...]
n14[env_multiplier = self._environment_mu...]
n15[business_multiplier = self._business_criti...]
n16[data_multiplier = self._data_sensitivi...]
n17[exposure_multiplier = self._exposure_multi...]
n18[compliance_multiplier = 1.0]
n19{for tag in compliance_tags}
n20[tag_lower = tag.lower()]
n21{if tag_lower in self._complian...}
n22[compliance_multiplier = max(compliance_multi...]
n23[]
n24[]
n25[context_multiplier = env_multiplier * 0.3...]
n26[logger.info(f&#39;Context multipliers - Env: ...]
n27[total_risk_score = 0.0]
n28[business_risk_score = 0.0]
n29[technical_risk_score = 0.0]
n30[priority_findings = []]
n31[severity_counts = {&#39;critical&#39...]
n32{for finding in findings}
n33[severity = finding.get(&#39;severit...]
n34{if severity not in self._risk_...}
n35[severity = &#39;low&#39;]
n36[]
n37[base_score = self._risk_matrix[se...]
n38[technical_risk_score += base_score]
n39[exploitability = finding.get(&#39;exploit...]
n40[exploit_multiplier = self._exploitability...]
n41[adjusted_tech_score = base_score * exploit...]
n42[adjusted_business_score = adjusted_tech_score ...]
n43{if asset_value &gt; 0 or user_bas...}
n44[impact_factor = self._calculate_busi...]
n45[adjusted_business_score *= impact_factor]
n46[]
n47[finding[&#39;calculated_technical_risk_score&...]
n48[finding[&#39;calculated_business_risk_score&a...]
n49[finding[&#39;context_multiplier&#39;&...]
n50[total_risk_score += adjusted_business_score]
n51[business_risk_score += adjusted_business_score]
n52[severity_counts[severity] += 1]
n53{if severity in [&#39;critical&#39;, &...}
n54[priority_findings.append(finding)]
n55[]
n56[]
n57[priority_findings.sort(key=lambda x: x.get(&&...]
n58[avg_business_risk = business_risk_score ...]
n59[overall_risk_level = self._determine_risk...]
n60[recommendations = self._generate_enhan...]
n61[business_impact = self._estimate_busin...]
n62[result = {&#39;overall_risk_score...]
n63[logger.info(f&#39;Risk assessment completed: ...]
n64[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n19
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n56
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 -->|Yes| n44
n43 -->|No| n46
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 -->|Yes| n54
n53 -->|No| n55
n54 --> n55
n55 --> n32
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n60
n60 --> n61
n61 --> n62
n62 --> n63
n63 --> n64
n64 --> n2
870. integration aiva integration analysis risk assessment engine Function compare risk trends
flowchart TB
n1([開始])
n2([結束])
n3['比較風險趨勢變化']
n4[current_score = current_assessment.g...]
n5[previous_score = previous_assessment....]
n6[score_change = current_score - prev...]
n7[trend = 'stable']
n8{if score_change > 1}
n9[trend = 'increasing']
n10{if score_change < -1}
n11[trend = 'decreasing']
n12[]
n13[]
n14[return {'current_score': cur...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;比較風險趨勢變化&#39;]
n4[current_score = current_assessment.g...]
n5[previous_score = previous_assessment....]
n6[score_change = current_score - prev...]
n7[trend = &#39;stable&#39;]
n8{if score_change &gt; 1}
n9[trend = &#39;increasing&#39;]
n10{if score_change &lt; -1}
n11[trend = &#39;decreasing&#39;]
n12[]
n13[]
n14[return {&#39;current_score&#39;: cur...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
871. integration aiva integration analysis vuln correlation analyzer Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._correlation_rules = {'xss&#...]
n4[self._attack_chains = [['info_disclos...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._correlation_rules = {&#39;xss&#...]
n4[self._attack_chains = [[&#39;info_disclos...]
n1 --> n3
n3 --> n4
n4 --> n2
872. integration aiva integration analysis vuln correlation analyzer Function analyze location clusters
flowchart TB
n1([開始])
n2([結束])
n3['分析漏洞位置聚集情況']
n4[clusters = []]
n5{for (location, findings) in vulns_by_location...}
n6{if len(findings) > 1}
n7[vuln_types = {f.get('vulnerabilit...]
n8[clusters.append({'location&#...]
n9[]
n10[]
n11[return sorted(clusters, key=lambda x:...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析漏洞位置聚集情況&#39;]
n4[clusters = []]
n5{for (location, findings) in vulns_by_location...}
n6{if len(findings) &gt; 1}
n7[vuln_types = {f.get(&#39;vulnerabilit...]
n8[clusters.append({&#39;location&#...]
n9[]
n10[]
n11[return sorted(clusters, key=lambda x:...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
873. integration aiva integration analysis vuln correlation analyzer Function are vulnerability types compatible
flowchart TB
n1([開始])
n2([結束])
n3['檢查 SAST 和 DAST 的漏洞類型是否匹配']
n4[type_mappings = {'sql_injection&#...]
n5[sast_normalized = sast_type.replace('-...]
n6[dast_normalized = dast_type.replace('-...]
n7{if sast_normalized == dast_nor...}
n8[return True]
n9[]
n10{for (category, variants) in type_mappings.ite...}
n11{if sast_normalized in variants...}
n12[return True]
n13[]
n14[]
n15[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n10
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查 SAST 和 DAST 的漏洞類型是否匹配&#39;]
n4[type_mappings = {&#39;sql_injection&#...]
n5[sast_normalized = sast_type.replace(&#39;-...]
n6[dast_normalized = dast_type.replace(&#39;-...]
n7{if sast_normalized == dast_nor...}
n8[return True]
n9[]
n10{for (category, variants) in type_mappings.ite...}
n11{if sast_normalized in variants...}
n12[return True]
n13[]
n14[]
n15[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n10
n14 --> n15
n15 --> n2
874. integration aiva integration analysis vuln correlation analyzer Function calculate flow impact
flowchart TB
n1([開始])
n2([結束])
n3['計算資料流的影響等級']
n4[sast_severity = sast_finding.get('se...]
n5[dast_severity = dast_finding.get('se...]
n6[severity_order = ['LOW', &...]
n7[sast_level = severity_order.index...]
n8[dast_level = severity_order.index...]
n9[max_level = max(sast_level, dast...]
n10[confirmed_level = min(max_level + 1, l...]
n11[return severity_order[confirmed_level...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算資料流的影響等級&#39;]
n4[sast_severity = sast_finding.get(&#39;se...]
n5[dast_severity = dast_finding.get(&#39;se...]
n6[severity_order = [&#39;LOW&#39;, &...]
n7[sast_level = severity_order.index...]
n8[dast_level = severity_order.index...]
n9[max_level = max(sast_level, dast...]
n10[confirmed_level = min(max_level + 1, l...]
n11[return severity_order[confirmed_level...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
875. integration aiva integration analysis vuln correlation analyzer Function calculate risk amplification
flowchart TB
n1([開始])
n2([結束])
n3['計算風險放大係數']
n4[base_amplification = 1.0]
n5{for group in correlation_groups}
n6[multiplier = group.get('multiplie...]
n7[related_count = len(group.get('relat...]
n8[base_amplification += (multiplier - 1.0) * (r...]
n9[]
n10{for chain in attack_chains}
n11[chain_risk = chain.get('chain_ris...]
n12[base_amplification += chain_risk / 20]
n13[]
n14[return round(min(base_amplification, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n5
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算風險放大係數&#39;]
n4[base_amplification = 1.0]
n5{for group in correlation_groups}
n6[multiplier = group.get(&#39;multiplie...]
n7[related_count = len(group.get(&#39;relat...]
n8[base_amplification += (multiplier - 1.0) * (r...]
n9[]
n10{for chain in attack_chains}
n11[chain_risk = chain.get(&#39;chain_ris...]
n12[base_amplification += chain_risk / 20]
n13[]
n14[return round(min(base_amplification, ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n5
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n2
876. integration aiva integration analysis vuln correlation analyzer Function check path correlation
flowchart TB
n1([開始])
n2([結束])
n3['檢查 SAST 程式碼位置與 DAST URL 路徑是否相關']
n4[code_file = sast_location.get('c...]
n5[url = dast_location.get('u...]
n6{if not code_file or not url}
n7[return False]
n8[]
n9[from urllib.parse import urlparse]
n10[parsed_url = urlparse(url)]
n11[url_path = parsed_url.path]
n12[url_segments = [seg for seg in url_...]
n13[code_segments = [seg for seg in code...]
n14[common_segments = set(url_segments) & ...]
n15[return len(common_segments) > 0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查 SAST 程式碼位置與 DAST URL 路徑是否相關&#39;]
n4[code_file = sast_location.get(&#39;c...]
n5[url = dast_location.get(&#39;u...]
n6{if not code_file or not url}
n7[return False]
n8[]
n9[from urllib.parse import urlparse]
n10[parsed_url = urlparse(url)]
n11[url_path = parsed_url.path]
n12[url_segments = [seg for seg in url_...]
n13[code_segments = [seg for seg in code...]
n14[common_segments = set(url_segments) & ...]
n15[return len(common_segments) &gt; 0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
877. integration aiva integration analysis vuln correlation analyzer Function count severities
flowchart TB
n1([開始])
n2([結束])
n3['統計嚴重程度分布']
n4[severity_counts = defaultdict(int)]
n5{for finding in findings}
n6[severity = finding.get('severit...]
n7[severity_counts[severity] += 1]
n8[]
n9[return dict(severity_counts)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;統計嚴重程度分布&#39;]
n4[severity_counts = defaultdict(int)]
n5{for finding in findings}
n6[severity = finding.get(&#39;severit...]
n7[severity_counts[severity] += 1]
n8[]
n9[return dict(severity_counts)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
878. integration aiva integration analysis vuln correlation analyzer Function describe attack chain
flowchart TB
n1([開始])
n2([結束])
n3['描述攻擊鏈']
n4[chain_str = ' → '.join(chain_...]
n5{if chain_pattern == ['info_dis...}
n6[return '資訊洩露 → SQL注入 → 權限提升攻擊鏈']
n7{if chain_pattern == ['xss', &...}
n8[return 'XSS → CSRF → 帳號接管攻擊鏈']
n9{if chain_pattern == ['ssrf', ...}
n10[return 'SSRF → 埠掃描 → 橫向移動攻擊鏈']
n11{if chain_pattern == ['lfi', &...}
n12[return 'LFI → 檔案洩露 → 遠端代碼執行攻擊鏈']
n13[return chain_str]
n14[]
n15[]
n16[]
n17[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n17
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n16
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n15
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;描述攻擊鏈&#39;]
n4[chain_str = &#39; → &#39;.join(chain_...]
n5{if chain_pattern == [&#39;info_dis...}
n6[return &#39;資訊洩露 → SQL注入 → 權限提升攻擊鏈&#39;]
n7{if chain_pattern == [&#39;xss&#39;, &...}
n8[return &#39;XSS → CSRF → 帳號接管攻擊鏈&#39;]
n9{if chain_pattern == [&#39;ssrf&#39;, ...}
n10[return &#39;SSRF → 埠掃描 → 橫向移動攻擊鏈&#39;]
n11{if chain_pattern == [&#39;lfi&#39;, &...}
n12[return &#39;LFI → 檔案洩露 → 遠端代碼執行攻擊鏈&#39;]
n13[return chain_str]
n14[]
n15[]
n16[]
n17[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n17
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n16
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n15
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
879. integration aiva integration analysis vuln correlation analyzer Function find correlation groups
flowchart TB
n1([開始])
n2([結束])
n3['尋找相關的漏洞組合']
n4[correlation_groups = []]
n5{for (vuln_type, findings) in vulns_by_type.ite...}
n6{if vuln_type in self._correlat...}
n7[rule = self._correlation_ru...]
n8[related = rule.get('related_ty...]
n9{if isinstance(related, str)}
n10[related_types = [related]]
n11{if isinstance(related, list | ...}
n12[related_types = list(related)]
n13[related_types = []]
n14[]
n15[]
n16[found_related = []]
n17{for related_type in related_types}
n18{if related_type in vulns_by_type}
n19[found_related.append({'type&#...]
n20[]
n21[]
n22{if found_related}
n23[raw_multiplier = rule.get('multiplier...]
n24[multiplier = 1.0]
n25{if isinstance(raw_multiplier, ...}
n26[multiplier = float(raw_multiplier...]
n27{if isinstance(raw_multiplier, ...}
n28[try]
n29[multiplier = float(raw_multiplier...]
n30[]
n31[except ValueError]
n32[multiplier = 1.0]
n33[]
n34[]
n35[correlation_groups.append({'primary_...]
n36[]
n37[]
n38[]
n39[return correlation_groups]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n38
n6 -->|Yes| n7
n6 -->|No| n37
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n15
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n17
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n36
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n34
n27 -->|Yes| n28
n27 -->|No| n33
n28 --> n29
n28 --> n31
n29 --> n30
n30 --> n33
n31 --> n32
n32 --> n30
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n5
n38 --> n39
n39 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;尋找相關的漏洞組合&#39;]
n4[correlation_groups = []]
n5{for (vuln_type, findings) in vulns_by_type.ite...}
n6{if vuln_type in self._correlat...}
n7[rule = self._correlation_ru...]
n8[related = rule.get(&#39;related_ty...]
n9{if isinstance(related, str)}
n10[related_types = [related]]
n11{if isinstance(related, list | ...}
n12[related_types = list(related)]
n13[related_types = []]
n14[]
n15[]
n16[found_related = []]
n17{for related_type in related_types}
n18{if related_type in vulns_by_type}
n19[found_related.append({&#39;type&#...]
n20[]
n21[]
n22{if found_related}
n23[raw_multiplier = rule.get(&#39;multiplier...]
n24[multiplier = 1.0]
n25{if isinstance(raw_multiplier, ...}
n26[multiplier = float(raw_multiplier...]
n27{if isinstance(raw_multiplier, ...}
n28[try]
n29[multiplier = float(raw_multiplier...]
n30[]
n31[except ValueError]
n32[multiplier = 1.0]
n33[]
n34[]
n35[correlation_groups.append({&#39;primary_...]
n36[]
n37[]
n38[]
n39[return correlation_groups]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n38
n6 -->|Yes| n7
n6 -->|No| n37
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n15
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n21
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n17
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n36
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n34
n27 -->|Yes| n28
n27 -->|No| n33
n28 --> n29
n28 --> n31
n29 --> n30
n30 --> n33
n31 --> n32
n32 --> n30
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n5
n38 --> n39
n39 --> n2
880. integration aiva integration analysis vuln correlation analyzer Function generate correlation summary
flowchart TB
n1([開始])
n2([結束])
n3['生成相關性分析摘要']
n4[return {'has_correlations': ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成相關性分析摘要&#39;]
n4[return {&#39;has_correlations&#39;: ...]
n1 --> n3
n3 --> n4
n4 --> n2
881. integration aiva integration analysis vuln correlation analyzer Function generate root cause recommendation
flowchart TB
n1([開始])
n2([結束])
n3['生成根因修復建議']
n4[comp_type = component['type'&...]
n5[comp_name = component['name'&...]
n6[count = component['count']]
n7[return f"建議重點審查和修復 {comp_type} &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成根因修復建議&#39;]
n4[comp_type = component[&#39;type&#39;&...]
n5[comp_name = component[&#39;name&#39;&...]
n6[count = component[&#39;count&#39;]]
n7[return f&quot;建議重點審查和修復 {comp_type} &&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
882. integration aiva integration analysis vuln correlation analyzer Function identify attack chains
flowchart TB
n1([開始])
n2([結束])
n3['識別可能的攻擊鏈']
n4[identified_chains = []]
n5{for chain_pattern in self._attack_chains}
n6[chain_matches = []]
n7[complete_chain = True]
n8{for step in chain_pattern}
n9{if step in vulns_by_type}
n10[chain_matches.append({'step&#...]
n11[complete_chain = False]
n12[break]
n13[]
n14[]
n15{if complete_chain}
n16[total_findings = 0]
n17{for match in chain_matches}
n18[count = match.get('count', 0...]
n19{if isinstance(count, int)}
n20[total_findings += count]
n21[]
n22[]
n23[chain_risk = len(chain_pattern) *...]
n24[identified_chains.append({'pattern&a...]
n25[]
n26[]
n27[return sorted(identified_chains, key=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n26
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n13
n11 --> n12
n12 --> n13
n13 --> n8
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n25
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n17
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n5
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;識別可能的攻擊鏈&#39;]
n4[identified_chains = []]
n5{for chain_pattern in self._attack_chains}
n6[chain_matches = []]
n7[complete_chain = True]
n8{for step in chain_pattern}
n9{if step in vulns_by_type}
n10[chain_matches.append({&#39;step&#...]
n11[complete_chain = False]
n12[break]
n13[]
n14[]
n15{if complete_chain}
n16[total_findings = 0]
n17{for match in chain_matches}
n18[count = match.get(&#39;count&#39;, 0...]
n19{if isinstance(count, int)}
n20[total_findings += count]
n21[]
n22[]
n23[chain_risk = len(chain_pattern) *...]
n24[identified_chains.append({&#39;pattern&a...]
n25[]
n26[]
n27[return sorted(identified_chains, key=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n26
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n13
n11 --> n12
n12 --> n13
n13 --> n8
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n25
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n17
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n5
n26 --> n27
n27 --> n2
883. integration aiva integration analysis vuln correlation analyzer Function identify common components
flowchart TB
n1([開始])
n2([結束])
n3['識別共用的程式碼元件']
n4[functions = []]
n5[classes = []]
n6[modules = []]
n7{for finding in findings}
n8[location = finding.get('locatio...]
n9[functions.append(location.get('functi...]
n10[classes.append(location.get('class_na...]
n11[modules.append(location.get('module_n...]
n12[]
n13[function_counts = defaultdict(int)]
n14[class_counts = defaultdict(int)]
n15[module_counts = defaultdict(int)]
n16{for func in functions}
n17{if func}
n18[function_counts[func] += 1]
n19[]
n20[]
n21{for cls in classes}
n22{if cls}
n23[class_counts[cls] += 1]
n24[]
n25[]
n26{for mod in modules}
n27{if mod}
n28[module_counts[mod] += 1]
n29[]
n30[]
n31{if function_counts and max(fun...}
n32[common_func = max(function_counts....]
n33[return {'type': '...]
n34[]
n35{if class_counts and max(class_...}
n36[common_class = max(class_counts.ite...]
n37[return {'type': '...]
n38[]
n39{if module_counts and max(modul...}
n40[common_module = max(module_counts.it...]
n41[return {'type': '...]
n42[]
n43[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n20
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n16
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n25
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n21
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n26
n30 --> n31
n31 -->|Yes| n32
n31 -->|No| n34
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n38
n36 --> n37
n37 --> n38
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n42
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;識別共用的程式碼元件&#39;]
n4[functions = []]
n5[classes = []]
n6[modules = []]
n7{for finding in findings}
n8[location = finding.get(&#39;locatio...]
n9[functions.append(location.get(&#39;functi...]
n10[classes.append(location.get(&#39;class_na...]
n11[modules.append(location.get(&#39;module_n...]
n12[]
n13[function_counts = defaultdict(int)]
n14[class_counts = defaultdict(int)]
n15[module_counts = defaultdict(int)]
n16{for func in functions}
n17{if func}
n18[function_counts[func] += 1]
n19[]
n20[]
n21{for cls in classes}
n22{if cls}
n23[class_counts[cls] += 1]
n24[]
n25[]
n26{for mod in modules}
n27{if mod}
n28[module_counts[mod] += 1]
n29[]
n30[]
n31{if function_counts and max(fun...}
n32[common_func = max(function_counts....]
n33[return {&#39;type&#39;: &#39...]
n34[]
n35{if class_counts and max(class_...}
n36[common_class = max(class_counts.ite...]
n37[return {&#39;type&#39;: &#39...]
n38[]
n39{if module_counts and max(modul...}
n40[common_module = max(module_counts.it...]
n41[return {&#39;type&#39;: &#39...]
n42[]
n43[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n20
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n16
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n25
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n21
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n26
n30 --> n31
n31 -->|Yes| n32
n31 -->|No| n34
n32 --> n33
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n38
n36 --> n37
n37 --> n38
n38 --> n39
n39 -->|Yes| n40
n39 -->|No| n42
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n2
884. integration aiva integration analysis vuln correlation analyzer Function analyze code level root cause
flowchart TB
n1([開始])
n2([結束])
n3['\n 程式碼層面的根因分析\n \n 識別多個...]
n4{if not findings}
n5[return {'root_causes': [...]
n6[]
n7[code_path_groups = defaultdict(list)]
n8{for finding in findings}
n9[location = finding.get('locatio...]
n10[file_path = location.get('file_p...]
n11{if file_path}
n12[code_path_groups[file_path].append(finding)]
n13[]
n14[]
n15[root_causes = []]
n16[derived_vulnerabilities = []]
n17{for (file_path, file_findings) in code_path_group...}
n18{if len(file_findings) < 2}
n19[continue]
n20[]
n21[common_components = self._identify_commo...]
n22{if common_components}
n23[root_cause = {'component_type...]
n24[root_causes.append(root_cause)]
n25{for finding in file_findings}
n26[derived_vulnerabilities.append({'vul...]
n27[]
n28[]
n29[]
n30[logger.info(f'Root cause analysis found &...]
n31[return {'root_causes': root_...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n29
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n28
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n25
n27 --> n28
n28 --> n17
n29 --> n30
n30 --> n31
n31 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 程式碼層面的根因分析\n \n 識別多個...]
n4{if not findings}
n5[return {&#39;root_causes&#39;: [...]
n6[]
n7[code_path_groups = defaultdict(list)]
n8{for finding in findings}
n9[location = finding.get(&#39;locatio...]
n10[file_path = location.get(&#39;file_p...]
n11{if file_path}
n12[code_path_groups[file_path].append(finding)]
n13[]
n14[]
n15[root_causes = []]
n16[derived_vulnerabilities = []]
n17{for (file_path, file_findings) in code_path_group...}
n18{if len(file_findings) &lt; 2}
n19[continue]
n20[]
n21[common_components = self._identify_commo...]
n22{if common_components}
n23[root_cause = {&#39;component_type&#3...]
n24[root_causes.append(root_cause)]
n25{for finding in file_findings}
n26[derived_vulnerabilities.append({&#39;vul...]
n27[]
n28[]
n29[]
n30[logger.info(f&#39;Root cause analysis found &...]
n31[return {&#39;root_causes&#39;: root_...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n29
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n28
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n25
n27 --> n28
n28 --> n17
n29 --> n30
n30 --> n31
n31 --> n2
885. integration aiva integration analysis vuln correlation analyzer Function analyze correlations
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析漏洞相關性\n\n Args:\n ...]
n4{if not findings}
n5[return {'total_findings': 0,...]
n6[]
n7[vulns_by_type = defaultdict(list)]
n8[vulns_by_location = defaultdict(list)]
n9{for finding in findings}
n10[vuln_type = finding.get('vulnera...]
n11[location = finding.get('locatio...]
n12[vulns_by_type[vuln_type].append(finding)]
n13[url_path = location.get('url'...]
n14[vulns_by_location[url_path].append(finding)]
n15[]
n16[correlation_groups = self._find_correlati...]
n17[attack_chains = self._identify_attac...]
n18[location_clusters = self._analyze_locati...]
n19[risk_amplification = self._calculate_risk...]
n20[result = {'total_findings': ...]
n21[logger.info(f'Correlation analysis comple...]
n22[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n15
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n9
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析漏洞相關性\n\n Args:\n ...]
n4{if not findings}
n5[return {&#39;total_findings&#39;: 0,...]
n6[]
n7[vulns_by_type = defaultdict(list)]
n8[vulns_by_location = defaultdict(list)]
n9{for finding in findings}
n10[vuln_type = finding.get(&#39;vulnera...]
n11[location = finding.get(&#39;locatio...]
n12[vulns_by_type[vuln_type].append(finding)]
n13[url_path = location.get(&#39;url&#39;...]
n14[vulns_by_location[url_path].append(finding)]
n15[]
n16[correlation_groups = self._find_correlati...]
n17[attack_chains = self._identify_attac...]
n18[location_clusters = self._analyze_locati...]
n19[risk_amplification = self._calculate_risk...]
n20[result = {&#39;total_findings&#39;: ...]
n21[logger.info(f&#39;Correlation analysis comple...]
n22[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n15
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n9
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
886. integration aiva integration analysis vuln correlation analyzer Function analyze sast dast correlation
flowchart TB
n1([開始])
n2([結束])
n3['\n SAST-DAST 資料流關聯分析\n \n ...]
n4{if not findings}
n5[return {'confirmed_flows': &...]
n6[]
n7[sast_findings = []]
n8[dast_findings = []]
n9{for finding in findings}
n10[scan_type = finding.get('scan_ty...]
n11[vuln_type = finding.get('vulnera...]
n12{if scan_type == 'sast' or &...}
n13[sast_findings.append(finding)]
n14{if scan_type == 'dast' or &...}
n15[dast_findings.append(finding)]
n16[]
n17[]
n18[]
n19[confirmed_flows = []]
n20[unconfirmed_sast = list(sast_findings)]
n21[orphan_dast = list(dast_findings)]
n22{for sast_finding in sast_findings}
n23[sast_location = sast_finding.get('lo...]
n24[sast_vuln_type = sast_finding.get('vu...]
n25{for dast_finding in dast_findings}
n26[dast_location = dast_finding.get('lo...]
n27[dast_vuln_type = dast_finding.get('vu...]
n28{if self._are_vulnerability_typ...}
n29{if self._check_path_correlatio...}
n30[confirmed_flow = {'sast_finding_id&&...]
n31[confirmed_flows.append(confirmed_flow)]
n32{if sast_finding in unconfirmed...}
n33[unconfirmed_sast.remove(sast_finding)]
n34[]
n35{if dast_finding in orphan_dast}
n36[orphan_dast.remove(dast_finding)]
n37[]
n38[]
n39[]
n40[]
n41[]
n42[logger.info(f'SAST-DAST correlation: ...]
n43[return {'confirmed_flows': c...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n18
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n9
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n41
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n40
n26 --> n27
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n39
n29 -->|Yes| n30
n29 -->|No| n38
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n34
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n37
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n25
n40 --> n22
n41 --> n42
n42 --> n43
n43 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n SAST-DAST 資料流關聯分析\n \n ...]
n4{if not findings}
n5[return {&#39;confirmed_flows&#39;: &...]
n6[]
n7[sast_findings = []]
n8[dast_findings = []]
n9{for finding in findings}
n10[scan_type = finding.get(&#39;scan_ty...]
n11[vuln_type = finding.get(&#39;vulnera...]
n12{if scan_type == &#39;sast&#39; or &&#...}
n13[sast_findings.append(finding)]
n14{if scan_type == &#39;dast&#39; or &&#...}
n15[dast_findings.append(finding)]
n16[]
n17[]
n18[]
n19[confirmed_flows = []]
n20[unconfirmed_sast = list(sast_findings)]
n21[orphan_dast = list(dast_findings)]
n22{for sast_finding in sast_findings}
n23[sast_location = sast_finding.get(&#39;lo...]
n24[sast_vuln_type = sast_finding.get(&#39;vu...]
n25{for dast_finding in dast_findings}
n26[dast_location = dast_finding.get(&#39;lo...]
n27[dast_vuln_type = dast_finding.get(&#39;vu...]
n28{if self._are_vulnerability_typ...}
n29{if self._check_path_correlatio...}
n30[confirmed_flow = {&#39;sast_finding_id&&...]
n31[confirmed_flows.append(confirmed_flow)]
n32{if sast_finding in unconfirmed...}
n33[unconfirmed_sast.remove(sast_finding)]
n34[]
n35{if dast_finding in orphan_dast}
n36[orphan_dast.remove(dast_finding)]
n37[]
n38[]
n39[]
n40[]
n41[]
n42[logger.info(f&#39;SAST-DAST correlation: ...]
n43[return {&#39;confirmed_flows&#39;: c...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n18
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n9
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n41
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n40
n26 --> n27
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n39
n29 -->|Yes| n30
n29 -->|No| n38
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n34
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n37
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n25
n40 --> n22
n41 --> n42
n42 --> n43
n43 --> n2
887. integration aiva integration attack path analyzer engine Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化引擎\n\n Args:\n ...]
n4[self.driver = GraphDatabase.driver...]
n5[logger.info(f'Connected to Neo4j at {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化引擎\n\n Args:\n ...]
n4[self.driver = GraphDatabase.driver...]
n5[logger.info(f&#39;Connected to Neo4j at {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
888. integration aiva integration attack path analyzer engine Function calculate risk score
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算風險分數\n\n Args:\n ...]
n4[severity_scores = {Severity.CRITICAL.v...]
n5[confidence_multiplier = {'CERTAIN&...]
n6[base_score = severity_scores.get(...]
n7[multiplier = confidence_multiplie...]
n8[return base_score * multiplier]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算風險分數\n\n Args:\n ...]
n4[severity_scores = {Severity.CRITICAL.v...]
n5[confidence_multiplier = {&#39;CERTAIN&&#...]
n6[base_score = severity_scores.get(...]
n7[multiplier = confidence_multiplie...]
n8[return base_score * multiplier]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
889. integration aiva integration attack path analyzer engine Function create attack edges
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據漏洞類型建立攻擊邊\n\n Args:\n ...]
n4[vuln_name = finding.vulnerabilit...]
n5{if vuln_name == 'SSRF'}
n6[session.run("\n MATCH (v:...]
n7{if vuln_name == 'SQLI'}
n8[session.run("\n MATCH (v:...]
n9{if vuln_name in ['IDOR', &...}
n10[session.run('\n MATCH (...]
n11{if vuln_name == 'XSS'}
n12[session.run("\n MATCH (v:...]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據漏洞類型建立攻擊邊\n\n Args:\n ...]
n4[vuln_name = finding.vulnerabilit...]
n5{if vuln_name == &#39;SSRF&#39;}
n6[session.run(&quot;\n MATCH (v:...]
n7{if vuln_name == &#39;SQLI&#39;}
n8[session.run(&quot;\n MATCH (v:...]
n9{if vuln_name in [&#39;IDOR&#39;, &...}
n10[session.run(&#39;\n MATCH (...]
n11{if vuln_name == &#39;XSS&#39;}
n12[session.run(&quot;\n MATCH (v:...]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n16
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
890. integration aiva integration attack path analyzer engine Function generate path description
flowchart TB
n1([開始])
n2([結束])
n3['生成攻擊路徑描述']
n4[steps = []]
n5{for (i, node) in enumerate(nodes)}
n6[node_labels = node.get('labels...]
n7[node_type = node_labels[0] if no...]
n8[node_name = node.get('name', ...]
n9{if i == 0}
n10[steps.append(f'起點: {node_name} ...]
n11{if i == len(nodes) - 1}
n12[steps.append(f'目標: {node_name} ...]
n13[edge = edges[i - 1] if i - ...]
n14[edge_type = edge.get('type', ...]
n15[steps.append(f'→ [{edge_type...]
n16[]
n17[]
n18[]
n19[return ' '.join(steps)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n18
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n5
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成攻擊路徑描述&#39;]
n4[steps = []]
n5{for (i, node) in enumerate(nodes)}
n6[node_labels = node.get(&#39;labels&#3...]
n7[node_type = node_labels[0] if no...]
n8[node_name = node.get(&#39;name&#39;, ...]
n9{if i == 0}
n10[steps.append(f&#39;起點: {node_name} ...]
n11{if i == len(nodes) - 1}
n12[steps.append(f&#39;目標: {node_name} ...]
n13[edge = edges[i - 1] if i - ...]
n14[edge_type = edge.get(&#39;type&#39;, ...]
n15[steps.append(f&#39;→ [{edge_type...]
n16[]
n17[]
n18[]
n19[return &#39; &#39;.join(steps)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n18
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n5
n18 --> n19
n19 --> n2
891. integration aiva integration attack path analyzer engine Function add asset
flowchart TB
n1([開始])
n2([結束])
n3['\n 新增資產節點\n\n Args:\n ...]
n4[with self.driv...]
n5[session.run('\n MERGE (...]
n6[session.run("\n MATCH (at...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 新增資產節點\n\n Args:\n ...]
n4[with self.driv...]
n5[session.run(&#39;\n MERGE (...]
n6[session.run(&quot;\n MATCH (at...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
892. integration aiva integration attack path analyzer engine Function add finding
flowchart TB
n1([開始])
n2([結束])
n3['\n 新增漏洞發現,建立資產與漏洞的關聯\n\n Args:...]
n4[with self.driv...]
n5[session.run('\n MERGE (...]
n6[target_url = str(finding.target.u...]
n7[session.run("\n MATCH (v:...]
n8[self._create_attack_edges(session, finding)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 新增漏洞發現,建立資產與漏洞的關聯\n\n Args:...]
n4[with self.driv...]
n5[session.run(&#39;\n MERGE (...]
n6[target_url = str(finding.target.u...]
n7[session.run(&quot;\n MATCH (v:...]
n8[self._create_attack_edges(session, finding)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
893. integration aiva integration attack path analyzer engine Function clear graph
flowchart TB
n1([開始])
n2([結束])
n3['清空圖(危險操作,僅用於測試)']
n4[with self.driv...]
n5[session.run('MATCH (n) DETACH DEL...]
n6[logger.warning('Graph cleared!...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清空圖(危險操作,僅用於測試)&#39;]
n4[with self.driv...]
n5[session.run(&#39;MATCH (n) DETACH DEL...]
n6[logger.warning(&#39;Graph cleared!&#3...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
894. integration aiva integration attack path analyzer engine Function close
flowchart TB
n1([開始])
n2([結束])
n3['關閉連線']
n4[self.driver.close()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;關閉連線&#39;]
n4[self.driver.close()]
n1 --> n3
n3 --> n4
n4 --> n2
895. integration aiva integration attack path analyzer engine Function find attack paths
flowchart TB
n1([開始])
n2([結束])
n3['\n 尋找從外部攻擊者到目標節點的攻擊路徑\n\n Args...]
n4[with self.driv...]
n5[query_str = f"\n ...]
n6[result = session.run(query_st...]
n7[paths = []]
n8{for record in result}
n9[path_data = record['path']]
n10[nodes = [dict(node) for node...]
n11[edges = [dict(rel) for rel i...]
n12[description = self._generate_path_...]
n13[paths.append(AttackPath(path_id=f'pat...]
n14[]
n15[logger.info(f'Found {len(paths...]
n16[return paths]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 尋找從外部攻擊者到目標節點的攻擊路徑\n\n Args...]
n4[with self.driv...]
n5[query_str = f&quot;\n ...]
n6[result = session.run(query_st...]
n7[paths = []]
n8{for record in result}
n9[path_data = record[&#39;path&#39;]]
n10[nodes = [dict(node) for node...]
n11[edges = [dict(rel) for rel i...]
n12[description = self._generate_path_...]
n13[paths.append(AttackPath(path_id=f&#39;pat...]
n14[]
n15[logger.info(f&#39;Found {len(paths&#...]
n16[return paths]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n16
n16 --> n2
896. integration aiva integration attack path analyzer engine Function find critical nodes
flowchart TB
n1([開始])
n2([結束])
n3['\n 尋找圖中的關鍵節點(高中心性節點)\n\n Args:...]
n4[with self.driv...]
n5[query_str = '\n M...]
n6[result = session.run(query_st...]
n7[nodes = []]
n8{for record in result}
n9[node = dict(record['n' ...]
n10[node['degree'] = record...]
n11[nodes.append(node)]
n12[]
n13[return nodes]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 尋找圖中的關鍵節點(高中心性節點)\n\n Args:...]
n4[with self.driv...]
n5[query_str = &#39;\n M...]
n6[result = session.run(query_st...]
n7[nodes = []]
n8{for record in result}
n9[node = dict(record[&#39;n&#39;	...]
n10[node[&#39;degree&#39;] = record&#...]
n11[nodes.append(node)]
n12[]
n13[return nodes]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n2
897. integration aiva integration attack path analyzer engine Function get vulnerability statistics
flowchart TB
n1([開始])
n2([結束])
n3['取得漏洞統計資訊']
n4[with self.driv...]
n5[result = session.run('\n ...]
n6[stats: dict[str, Any] = {'total&...]
n7{for record in result}
n8[severity = record['severity'&...]
n9[count = record['count']]
n10[stats['by_severity'][...]
n11[stats['total'] += count]
n12[]
n13[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取得漏洞統計資訊&#39;]
n4[with self.driv...]
n5[result = session.run(&#39;\n ...]
n6[stats: dict[str, Any] = {&#39;total&...]
n7{for record in result}
n8[severity = record[&#39;severity&#39;&...]
n9[count = record[&#39;count&#39;]]
n10[stats[&#39;by_severity&#39;][...]
n11[stats[&#39;total&#39;] += count]
n12[]
n13[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n2
898. integration aiva integration attack path analyzer engine Function initialize graph
flowchart TB
n1([開始])
n2([結束])
n3['初始化圖結構(建立索引和約束)']
n4[with self.driv...]
n5[session.run('CREATE CONSTRAINT asset_id I...]
n6[session.run('CREATE CONSTRAINT vuln_id IF...]
n7[session.run('CREATE CONSTRAINT cred_id IF...]
n8[session.run('CREATE INDEX asset_type IF N...]
n9[session.run('CREATE INDEX vuln_severity I...]
n10[session.run("\n MERGE (at...]
n11[logger.info('Graph structure initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化圖結構(建立索引和約束)&#39;]
n4[with self.driv...]
n5[session.run(&#39;CREATE CONSTRAINT asset_id I...]
n6[session.run(&#39;CREATE CONSTRAINT vuln_id IF...]
n7[session.run(&#39;CREATE CONSTRAINT cred_id IF...]
n8[session.run(&#39;CREATE INDEX asset_type IF N...]
n9[session.run(&#39;CREATE INDEX vuln_severity I...]
n10[session.run(&quot;\n MERGE (at...]
n11[logger.info(&#39;Graph structure initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
899. integration aiva integration attack path analyzer nlp recommender Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化推薦器']
n4[self._vuln_descriptions = {'SQLI&...]
n5[self._node_descriptions = {NodeType.ATTACKER: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化推薦器&#39;]
n4[self._vuln_descriptions = {&#39;SQLI&...]
n5[self._node_descriptions = {NodeType.ATTACKER: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
900. integration aiva integration attack path analyzer nlp recommender Function calculate priority score
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算優先級分數\n\n 考慮因素:\n ...]
n4[base_risk = min(path.total_risk_...]
n5{if path.length <= 3}
n6[length_score = 25]
n7{if path.length <= 6}
n8[length_score = 15]
n9[length_score = 5]
n10[]
n11[]
n12[target_node = path.nodes[-1] if pa...]
n13[target_labels = target_node.get('lab...]
n14[sensitivity_scores = {'Database&#...]
n15[sensitivity_score = 0]
n16{for label in target_labels}
n17[sensitivity_score = max(sensitivity_scor...]
n18[]
n19[critical_vuln_count = sum((1 for node in p...]
n20[vuln_score = min(critical_vuln_co...]
n21[total_score = base_risk + length_s...]
n22[return min(total_score, 100.0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n11
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n16
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算優先級分數\n\n 考慮因素:\n ...]
n4[base_risk = min(path.total_risk_...]
n5{if path.length &lt;= 3}
n6[length_score = 25]
n7{if path.length &lt;= 6}
n8[length_score = 15]
n9[length_score = 5]
n10[]
n11[]
n12[target_node = path.nodes[-1] if pa...]
n13[target_labels = target_node.get(&#39;lab...]
n14[sensitivity_scores = {&#39;Database&#...]
n15[sensitivity_score = 0]
n16{for label in target_labels}
n17[sensitivity_score = max(sensitivity_scor...]
n18[]
n19[critical_vuln_count = sum((1 for node in p...]
n20[vuln_score = min(critical_vuln_co...]
n21[total_score = base_risk + length_s...]
n22[return min(total_score, 100.0)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n11
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n16
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
901. integration aiva integration attack path analyzer nlp recommender Function determine risk level
flowchart TB
n1([開始])
n2([結束])
n3['判斷風險等級']
n4{if priority_score >= 80 or pat...}
n5[return RiskLevel.CRITICAL]
n6{if priority_score >= 60 or pat...}
n7[return RiskLevel.HIGH]
n8{if priority_score >= 40 or pat...}
n9[return RiskLevel.MEDIUM]
n10[return RiskLevel.LOW]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;判斷風險等級&#39;]
n4{if priority_score &gt;= 80 or pat...}
n5[return RiskLevel.CRITICAL]
n6{if priority_score &gt;= 60 or pat...}
n7[return RiskLevel.HIGH]
n8{if priority_score &gt;= 40 or pat...}
n9[return RiskLevel.MEDIUM]
n10[return RiskLevel.LOW]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
902. integration aiva integration attack path analyzer nlp recommender Function estimate effort
flowchart TB
n1([開始])
n2([結束])
n3['估算修復工作量']
n4[vuln_count = sum((1 for node in p...]
n5[critical_count = sum((1 for node in p...]
n6{if critical_count >= 2 or vuln...}
n7[return '高 (預估 2-4 週,需要多個團隊協作)&...]
n8{if critical_count >= 1 or vuln...}
n9[return '中 (預估 1-2 週,需要開發和測試資源)&...]
n10[return '低 (預估 2-5 天,可由單一團隊完成)&...]
n11[]
n12[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;估算修復工作量&#39;]
n4[vuln_count = sum((1 for node in p...]
n5[critical_count = sum((1 for node in p...]
n6{if critical_count &gt;= 2 or vuln...}
n7[return &#39;高 (預估 2-4 週,需要多個團隊協作)&...]
n8{if critical_count &gt;= 1 or vuln...}
n9[return &#39;中 (預估 1-2 週,需要開發和測試資源)&&#...]
n10[return &#39;低 (預估 2-5 天,可由單一團隊完成)&...]
n11[]
n12[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n2
903. integration aiva integration attack path analyzer nlp recommender Function estimate risk reduction
flowchart TB
n1([開始])
n2([結束])
n3['\n 估算修復後的風險降低程度\n\n Returns:\n...]
n4[risk_score = path.total_risk_scor...]
n5{if risk_score >= 25}
n6[return 95.0]
n7{if risk_score >= 15}
n8[return 85.0]
n9{if risk_score >= 8}
n10[return 70.0]
n11[return 50.0]
n12[]
n13[]
n14[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n14
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 估算修復後的風險降低程度\n\n Returns:\n...]
n4[risk_score = path.total_risk_scor...]
n5{if risk_score &gt;= 25}
n6[return 95.0]
n7{if risk_score &gt;= 15}
n8[return 85.0]
n9{if risk_score &gt;= 8}
n10[return 70.0]
n11[return 50.0]
n12[]
n13[]
n14[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n14
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
904. integration aiva integration attack path analyzer nlp recommender Function extract affected assets
flowchart TB
n1([開始])
n2([結束])
n3['提取受影響的資產']
n4[assets = []]
n5{for node in path.nodes}
n6{if 'Asset' in node.get(&&...}
n7[asset_value = node.get('value'...]
n8[assets.append(asset_value)]
n9[]
n10[]
n11[return assets]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取受影響的資產&#39;]
n4[assets = []]
n5{for node in path.nodes}
n6{if &#39;Asset&#39; in node.get(&&...}
n7[asset_value = node.get(&#39;value&#39...]
n8[assets.append(asset_value)]
n9[]
n10[]
n11[return assets]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
905. integration aiva integration attack path analyzer nlp recommender Function generate business impact
flowchart TB
n1([開始])
n2([結束])
n3['生成業務影響說明']
n4[impact = '## 業務影響評估\n\n']
n5{if risk_level == RiskLevel.CRI...}
n6[impact += '### 🚨 嚴重業務影響\n\n&&...]
n7[impact += '此攻擊路徑若被利用,可能導致:\n\n']
n8[impact += '- **資料洩露風險**: 極高,敏感資料可能完全洩露\n&...]
n9[impact += '- **服務中斷風險**: 高,可能導致服務完全停擺\n&&...]
n10[impact += '- **財務損失**: 可能超過數百萬元,包含罰款、補償、商譽損失\...]
n11[impact += '- **法規合規**: 可能違反 GDPR、PCI-DSS 等法規,...]
n12[impact += '- **商譽損害**: 嚴重,可能導致客戶流失和媒體負面報導\n\n...]
n13[impact += '**建議行動**: 立即召集緊急會議,24小時內完成修復\n&...]
n14{if risk_level == RiskLevel.HIGH}
n15[impact += '### ⚠️ 高度業務影響\n\n&...]
n16[impact += '此攻擊路徑具有顯著風險:\n\n']
n17[impact += '- **資料洩露風險**: 高,部分敏感資料可能洩露\n&&...]
n18[impact += '- **服務中斷風險**: 中等,可能影響部分服務\n&...]
n19[impact += '- **財務損失**: 可能達到數十萬元\n']
n20[impact += '- **法規合規**: 需要注意合規風險\n']
n21[impact += '- **商譽損害**: 中等,需要謹慎處理\n\n&#...]
n22[impact += '**建議行動**: 優先處理,一週內完成修復\n']
n23{if risk_level == RiskLevel.MEDIUM}
n24[impact += '### ⚡ 中度業務影響\n\n&&...]
n25[impact += '此攻擊路徑需要關注:\n\n']
n26[impact += '- **資料洩露風險**: 中等\n']
n27[impact += '- **服務中斷風險**: 低\n']
n28[impact += '- **財務損失**: 可能數萬元\n']
n29[impact += '- **商譽損害**: 有限\n\n']
n30[impact += '**建議行動**: 納入修復計劃,一個月內完成\n&#...]
n31[impact += '### ℹ️ 低度業務影響\n\n&...]
n32[impact += '此攻擊路徑風險較低,但仍需注意。\n\n']
n33[impact += '**建議行動**: 常規維護週期內處理\n']
n34[]
n35[]
n36[]
n37[target_node = path.nodes[-1] if pa...]
n38[target_labels = target_node.get('lab...]
n39[impact += '\n### 受影響的利益相關者\n\n&am...]
n40{if 'Database' in target_labels}
n41[impact += '- **資料所有者**: 客戶、使用者\n']
n42[impact += '- **負責團隊**: 資安團隊、DBA 團隊、應用開發團隊\n&a...]
n43[impact += '- **需通知對象**: CISO、法務、客服、公關\n&&...]
n44{if 'InternalNetwork' in target...}
n45[impact += '- **負責團隊**: 網路安全團隊、基礎架構團隊\n&...]
n46[impact += '- **需通知對象**: CISO、IT 主管\n&#...]
n47[impact += '- **負責團隊**: 資安團隊、應用開發團隊\n&#...]
n48[impact += '- **需通知對象**: CISO、產品負責人\n&#...]
n49[]
n50[]
n51[return impact]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n36
n14 -->|Yes| n15
n14 -->|No| n23
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n35
n23 -->|Yes| n24
n23 -->|No| n31
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n34
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 -->|Yes| n41
n40 -->|No| n44
n41 --> n42
n42 --> n43
n43 --> n50
n44 -->|Yes| n45
n44 -->|No| n47
n45 --> n46
n46 --> n49
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成業務影響說明&#39;]
n4[impact = &#39;## 業務影響評估\n\n&#39;]
n5{if risk_level == RiskLevel.CRI...}
n6[impact += &#39;### 🚨 嚴重業務影響\n\n&&...]
n7[impact += &#39;此攻擊路徑若被利用,可能導致:\n\n&#39;]
n8[impact += &#39;- **資料洩露風險**: 極高,敏感資料可能完全洩露\n&...]
n9[impact += &#39;- **服務中斷風險**: 高,可能導致服務完全停擺\n&&...]
n10[impact += &#39;- **財務損失**: 可能超過數百萬元,包含罰款、補償、商譽損失\...]
n11[impact += &#39;- **法規合規**: 可能違反 GDPR、PCI-DSS 等法規,...]
n12[impact += &#39;- **商譽損害**: 嚴重,可能導致客戶流失和媒體負面報導\n\n...]
n13[impact += &#39;**建議行動**: 立即召集緊急會議,24小時內完成修復\n&...]
n14{if risk_level == RiskLevel.HIGH}
n15[impact += &#39;### ⚠️ 高度業務影響\n\n&...]
n16[impact += &#39;此攻擊路徑具有顯著風險:\n\n&#39;]
n17[impact += &#39;- **資料洩露風險**: 高,部分敏感資料可能洩露\n&&...]
n18[impact += &#39;- **服務中斷風險**: 中等,可能影響部分服務\n&&#...]
n19[impact += &#39;- **財務損失**: 可能達到數十萬元\n&#39;]
n20[impact += &#39;- **法規合規**: 需要注意合規風險\n&#39;]
n21[impact += &#39;- **商譽損害**: 中等,需要謹慎處理\n\n&#...]
n22[impact += &#39;**建議行動**: 優先處理,一週內完成修復\n&#39;]
n23{if risk_level == RiskLevel.MEDIUM}
n24[impact += &#39;### ⚡ 中度業務影響\n\n&&...]
n25[impact += &#39;此攻擊路徑需要關注:\n\n&#39;]
n26[impact += &#39;- **資料洩露風險**: 中等\n&#39;]
n27[impact += &#39;- **服務中斷風險**: 低\n&#39;]
n28[impact += &#39;- **財務損失**: 可能數萬元\n&#39;]
n29[impact += &#39;- **商譽損害**: 有限\n\n&#39;]
n30[impact += &#39;**建議行動**: 納入修復計劃,一個月內完成\n&#...]
n31[impact += &#39;### ℹ️ 低度業務影響\n\n&...]
n32[impact += &#39;此攻擊路徑風險較低,但仍需注意。\n\n&#39;]
n33[impact += &#39;**建議行動**: 常規維護週期內處理\n&#39;]
n34[]
n35[]
n36[]
n37[target_node = path.nodes[-1] if pa...]
n38[target_labels = target_node.get(&#39;lab...]
n39[impact += &#39;\n### 受影響的利益相關者\n\n&am...]
n40{if &#39;Database&#39; in target_labels}
n41[impact += &#39;- **資料所有者**: 客戶、使用者\n&#39;]
n42[impact += &#39;- **負責團隊**: 資安團隊、DBA 團隊、應用開發團隊\n&a...]
n43[impact += &#39;- **需通知對象**: CISO、法務、客服、公關\n&&...]
n44{if &#39;InternalNetwork&#39; in target...}
n45[impact += &#39;- **負責團隊**: 網路安全團隊、基礎架構團隊\n&&#...]
n46[impact += &#39;- **需通知對象**: CISO、IT 主管\n&#...]
n47[impact += &#39;- **負責團隊**: 資安團隊、應用開發團隊\n&#...]
n48[impact += &#39;- **需通知對象**: CISO、產品負責人\n&#...]
n49[]
n50[]
n51[return impact]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n36
n14 -->|Yes| n15
n14 -->|No| n23
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n35
n23 -->|Yes| n24
n23 -->|No| n31
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n34
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 --> n39
n39 --> n40
n40 -->|Yes| n41
n40 -->|No| n44
n41 --> n42
n42 --> n43
n43 --> n50
n44 -->|Yes| n45
n44 -->|No| n47
n45 --> n46
n46 --> n49
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n2
906. integration aiva integration attack path analyzer nlp recommender Function generate executive summary
flowchart TB
n1([開始])
n2([結束])
n3['生成執行摘要(給管理層看的)']
n4[vuln_count = sum((1 for node in p...]
n5[target_node = path.nodes[-1] if pa...]
n6[target_type = self._get_node_type_...]
n7[critical_vulns = [node.get('name&...]
n8[risk_emoji = {RiskLevel.CRITICAL:...]
n9[summary = f'{risk_emoji[risk_l...]
n10{if risk_level in [RiskLevel.CR...}
n11[summary += f'發現一條高風險攻擊路徑,外部攻擊者可透過 {vuln_...]
n12[summary += f'最終到達 **{target_type}**...]
n13[summary += f'發現一條潛在攻擊路徑,涉及 {vuln_count...]
n14[summary += f'可能影響 **{target_type}**...]
n15[]
n16{if critical_vulns}
n17[summary += f"\n\n**關鍵漏洞**: {', ...]
n18{if len(critical_vulns) > 3}
n19[summary += f' 及其他 {len(critical_vuln...]
n20[]
n21[]
n22[summary += f'\n\n**路徑長度**: {path.length&...]
n23[summary += f' | **風險評分**: {path.tot...]
n24[return summary]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n21
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成執行摘要(給管理層看的)&#39;]
n4[vuln_count = sum((1 for node in p...]
n5[target_node = path.nodes[-1] if pa...]
n6[target_type = self._get_node_type_...]
n7[critical_vulns = [node.get(&#39;name&...]
n8[risk_emoji = {RiskLevel.CRITICAL:...]
n9[summary = f&#39;{risk_emoji[risk_l...]
n10{if risk_level in [RiskLevel.CR...}
n11[summary += f&#39;發現一條高風險攻擊路徑,外部攻擊者可透過 {vuln_...]
n12[summary += f&#39;最終到達 **{target_type}**...]
n13[summary += f&#39;發現一條潛在攻擊路徑,涉及 {vuln_count&#...]
n14[summary += f&#39;可能影響 **{target_type}**...]
n15[]
n16{if critical_vulns}
n17[summary += f&quot;\n\n**關鍵漏洞**: {&#39;, ...]
n18{if len(critical_vulns) &gt; 3}
n19[summary += f&#39; 及其他 {len(critical_vuln...]
n20[]
n21[]
n22[summary += f&#39;\n\n**路徑長度**: {path.length&...]
n23[summary += f&#39; | **風險評分**: {path.tot...]
n24[return summary]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n21
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
907. integration aiva integration attack path analyzer nlp recommender Function generate remediation steps
flowchart TB
n1([開始])
n2([結束])
n3['生成修復步驟(按優先級排序)']
n4[steps = []]
n5[vulnerabilities = [node for node in pa...]
n6[severity_order = {'CRITICAL'...]
n7[vulnerabilities.sort(key=lambda v: severity_order....]
n8{for (i, vuln) in enumerate(vulnera...}
n9[vuln_name = vuln.get('name', ...]
n10[severity = vuln.get('severity'...]
n11[step = f'【優先級 {i}】修復 {vuln_...]
n12{if vuln_name == 'SQLI'}
n13[step += ' - 使用參數化查詢 (Prepared Statements...]
n14[step += ' - 啟用 ORM 框架的參數綁定功能\n']
n15[step += ' - 實施輸入驗證和過濾\n']
n16[step += ' - 使用最小權限資料庫帳號\n']
n17[step += ' - 部署 WAF 規則攔截 SQL 注入攻擊']
n18{if vuln_name == 'XSS'}
n19[step += ' - 實施 Content Security Policy (...]
n20[step += ' - 對所有使用者輸入進行 HTML 編碼\n']
n21[step += ' - 使用安全的模板引擎\n']
n22[step += ' - 啟用 HttpOnly 和 Secure Cookie 標誌\n...]
n23[step += ' - 部署 WAF XSS 防護規則']
n24{if vuln_name == 'SSRF'}
n25[step += ' - 實施嚴格的 URL 白名單\n']
n26[step += ' - 禁止存取內部 IP 範圍 (RFC1918)\n...]
n27[step += ' - 禁止存取雲端元資料端點 (169.254.169.254...]
n28[step += ' - 使用獨立的網路隔離環境\n']
n29[step += ' - 限制出站連線']
n30{if vuln_name in ['IDOR', &...}
n31[step += ' - 實施嚴格的授權檢查\n']
n32[step += ' - 使用 UUID 取代順序 ID\n']
n33[step += ' - 在每個端點驗證使用者權限\n']
n34[step += ' - 實施 RBAC 或 ABAC 存取控制\n']
n35[step += ' - 記錄所有授權失敗嘗試']
n36{if vuln_name == 'AUTHENTICATIO...}
n37[step += ' - 修復認證邏輯漏洞\n']
n38[step += ' - 實施多因素認證 (MFA)\n&#...]
n39[step += ' - 加強 Session 管理\n']
n40[step += ' - 實施帳號鎖定機制\n']
n41[step += ' - 定期審查認證程式碼']
n42{if vuln_name == 'RCE'}
n43[step += ' - 【緊急】立即修補已知 RCE 漏洞\n']
n44[step += ' - 禁止執行使用者提供的程式碼\n']
n45[step += ' - 實施應用程式沙箱\n']
n46[step += ' - 移除或禁用危險函數\n']
n47[step += ' - 部署 Runtime Application Self-Prot...]
n48[step += f" - 參考 CWE-{vuln.get(&...]
n49[step += ' - 實施輸入驗證和輸出編碼\n']
n50[step += ' - 進行安全程式碼審查\n']
n51[step += ' - 部署相應的安全控制措施']
n52[]
n53[]
n54[]
n55[]
n56[]
n57[]
n58[steps.append(step)]
n59[]
n60[steps.append('【通用防護】加強整體安全態勢:\n - 部署 Web...]
n61[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n59
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n18
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n57
n18 -->|Yes| n19
n18 -->|No| n24
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n56
n24 -->|Yes| n25
n24 -->|No| n30
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n55
n30 -->|Yes| n31
n30 -->|No| n36
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n54
n36 -->|Yes| n37
n36 -->|No| n42
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n53
n42 -->|Yes| n43
n42 -->|No| n48
n43 --> n44
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n52
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 --> n56
n56 --> n57
n57 --> n58
n58 --> n8
n59 --> n60
n60 --> n61
n61 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成修復步驟(按優先級排序)&#39;]
n4[steps = []]
n5[vulnerabilities = [node for node in pa...]
n6[severity_order = {&#39;CRITICAL&#39;...]
n7[vulnerabilities.sort(key=lambda v: severity_order....]
n8{for (i, vuln) in enumerate(vulnera...}
n9[vuln_name = vuln.get(&#39;name&#39;, ...]
n10[severity = vuln.get(&#39;severity&#39...]
n11[step = f&#39;【優先級 {i}】修復 {vuln_...]
n12{if vuln_name == &#39;SQLI&#39;}
n13[step += &#39; - 使用參數化查詢 (Prepared Statements...]
n14[step += &#39; - 啟用 ORM 框架的參數綁定功能\n&#39;]
n15[step += &#39; - 實施輸入驗證和過濾\n&#39;]
n16[step += &#39; - 使用最小權限資料庫帳號\n&#39;]
n17[step += &#39; - 部署 WAF 規則攔截 SQL 注入攻擊&#39;]
n18{if vuln_name == &#39;XSS&#39;}
n19[step += &#39; - 實施 Content Security Policy (...]
n20[step += &#39; - 對所有使用者輸入進行 HTML 編碼\n&#39;]
n21[step += &#39; - 使用安全的模板引擎\n&#39;]
n22[step += &#39; - 啟用 HttpOnly 和 Secure Cookie 標誌\n...]
n23[step += &#39; - 部署 WAF XSS 防護規則&#39;]
n24{if vuln_name == &#39;SSRF&#39;}
n25[step += &#39; - 實施嚴格的 URL 白名單\n&#39;]
n26[step += &#39; - 禁止存取內部 IP 範圍 (RFC1918)\n...]
n27[step += &#39; - 禁止存取雲端元資料端點 (169.254.169.254...]
n28[step += &#39; - 使用獨立的網路隔離環境\n&#39;]
n29[step += &#39; - 限制出站連線&#39;]
n30{if vuln_name in [&#39;IDOR&#39;, &...}
n31[step += &#39; - 實施嚴格的授權檢查\n&#39;]
n32[step += &#39; - 使用 UUID 取代順序 ID\n&#39;]
n33[step += &#39; - 在每個端點驗證使用者權限\n&#39;]
n34[step += &#39; - 實施 RBAC 或 ABAC 存取控制\n&#39;]
n35[step += &#39; - 記錄所有授權失敗嘗試&#39;]
n36{if vuln_name == &#39;AUTHENTICATIO...}
n37[step += &#39; - 修復認證邏輯漏洞\n&#39;]
n38[step += &#39; - 實施多因素認證 (MFA)\n&#...]
n39[step += &#39; - 加強 Session 管理\n&#39;]
n40[step += &#39; - 實施帳號鎖定機制\n&#39;]
n41[step += &#39; - 定期審查認證程式碼&#39;]
n42{if vuln_name == &#39;RCE&#39;}
n43[step += &#39; - 【緊急】立即修補已知 RCE 漏洞\n&#39;]
n44[step += &#39; - 禁止執行使用者提供的程式碼\n&#39;]
n45[step += &#39; - 實施應用程式沙箱\n&#39;]
n46[step += &#39; - 移除或禁用危險函數\n&#39;]
n47[step += &#39; - 部署 Runtime Application Self-Prot...]
n48[step += f&quot; - 參考 CWE-{vuln.get(&...]
n49[step += &#39; - 實施輸入驗證和輸出編碼\n&#39;]
n50[step += &#39; - 進行安全程式碼審查\n&#39;]
n51[step += &#39; - 部署相應的安全控制措施&#39;]
n52[]
n53[]
n54[]
n55[]
n56[]
n57[]
n58[steps.append(step)]
n59[]
n60[steps.append(&#39;【通用防護】加強整體安全態勢:\n - 部署 Web...]
n61[return steps]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n59
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n18
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n57
n18 -->|Yes| n19
n18 -->|No| n24
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n56
n24 -->|Yes| n25
n24 -->|No| n30
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n55
n30 -->|Yes| n31
n30 -->|No| n36
n31 --> n32
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n54
n36 -->|Yes| n37
n36 -->|No| n42
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n53
n42 -->|Yes| n43
n42 -->|No| n48
n43 --> n44
n44 --> n45
n45 --> n46
n46 --> n47
n47 --> n52
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 --> n56
n56 --> n57
n57 --> n58
n58 --> n8
n59 --> n60
n60 --> n61
n61 --> n2
908. integration aiva integration attack path analyzer nlp recommender Function generate technical explanation
flowchart TB
n1([開始])
n2([結束])
n3['生成技術解釋(給技術團隊看的)']
n4[explanation = '## 攻擊路徑技術分析\n\n&...]
n5[explanation += '### 攻擊步驟\n\n&...]
n6{for (i, node) in enumerate(path.no...}
n7[node_labels = node.get('labels...]
n8[node_type = node_labels[0] if no...]
n9{if i == 0}
n10[explanation += f'**步驟 {i + 1}: 起點 -...]
n11[explanation += ' - 攻擊者從外部網路發起攻擊\n\n&#...]
n12{if 'Vulnerability' in node_labels}
n13[vuln_name = node.get('name', ...]
n14[severity = node.get('severity'...]
n15[cwe = node.get('cwe', &...]
n16[explanation += f'**步驟 {i + 1}: 利用漏洞...]
n17[explanation += f' - **嚴重程度**: {severity...]
n18[explanation += f' - **CWE 編號**: {cwe...]
n19{if vuln_name in self._vuln_des...}
n20[vuln_info = self._vuln_descripti...]
n21[explanation += f" - **影響**: {vuln_info[...]
n22[explanation += f" - **常見利用方式**: {vuln_info...]
n23[]
n24{if i < len(path.edges)}
n25[edge = path.edges[i]]
n26[edge_type = edge.get('type', ...]
n27[edge_risk = edge.get('risk', ...]
n28[explanation += f' - **攻擊效果**: {self._tr...]
n29[explanation += f' - **路徑風險**: {edge_ris...]
n30[]
n31[explanation += '\n']
n32{if i == len(path.nodes) - 1}
n33[explanation += f'**步驟 {i + 1}: 攻擊目標...]
n34[explanation += f' - 攻擊者成功到達 {self._get_...]
n35[explanation += ' - 可能的後果:\n']
n36{if 'Database' in node_labels}
n37[explanation += ' - 竊取、篡改或刪除敏感資料\n&#...]
n38[explanation += ' - 獲取使用者憑證和個人資訊\n&#...]
n39[explanation += ' - 破壞資料完整性\n']
n40{if 'Credential' in node_labels}
n41[explanation += ' - 劫持使用者帳號\n']
n42[explanation += ' - 橫向移動到其他系統\n']
n43[explanation += ' - 持久化存取\n']
n44{if 'InternalNetwork' in node_l...}
n45[explanation += ' - 探測內部網路拓撲\n']
n46[explanation += ' - 存取內部服務和 API\n']
n47[explanation += ' - 建立跳板進行進一步攻擊\n']
n48{if 'APIEndpoint' in node_labels}
n49[explanation += ' - 未授權存取敏感 API\n']
n50[explanation += ' - 資料洩露或篡改\n']
n51[explanation += ' - 業務邏輯繞過\n']
n52[]
n53[]
n54[]
n55[]
n56[explanation += '\n']
n57[]
n58[]
n59[]
n60[]
n61[return explanation]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n60
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n59
n12 -->|Yes| n13
n12 -->|No| n32
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n23
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n30
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n58
n32 -->|Yes| n33
n32 -->|No| n57
n33 --> n34
n34 --> n35
n35 --> n36
n36 -->|Yes| n37
n36 -->|No| n40
n37 --> n38
n38 --> n39
n39 --> n55
n40 -->|Yes| n41
n40 -->|No| n44
n41 --> n42
n42 --> n43
n43 --> n54
n44 -->|Yes| n45
n44 -->|No| n48
n45 --> n46
n46 --> n47
n47 --> n53
n48 -->|Yes| n49
n48 -->|No| n52
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 --> n56
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n6
n60 --> n61
n61 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成技術解釋(給技術團隊看的)&#39;]
n4[explanation = &#39;## 攻擊路徑技術分析\n\n&&#...]
n5[explanation += &#39;### 攻擊步驟\n\n&...]
n6{for (i, node) in enumerate(path.no...}
n7[node_labels = node.get(&#39;labels&#3...]
n8[node_type = node_labels[0] if no...]
n9{if i == 0}
n10[explanation += f&#39;**步驟 {i + 1}: 起點 -...]
n11[explanation += &#39; - 攻擊者從外部網路發起攻擊\n\n&#...]
n12{if &#39;Vulnerability&#39; in node_labels}
n13[vuln_name = node.get(&#39;name&#39;, ...]
n14[severity = node.get(&#39;severity&#39...]
n15[cwe = node.get(&#39;cwe&#39;, &&#...]
n16[explanation += f&#39;**步驟 {i + 1}: 利用漏洞...]
n17[explanation += f&#39; - **嚴重程度**: {severity...]
n18[explanation += f&#39; - **CWE 編號**: {cwe...]
n19{if vuln_name in self._vuln_des...}
n20[vuln_info = self._vuln_descripti...]
n21[explanation += f&quot; - **影響**: {vuln_info[...]
n22[explanation += f&quot; - **常見利用方式**: {vuln_info...]
n23[]
n24{if i &lt; len(path.edges)}
n25[edge = path.edges[i]]
n26[edge_type = edge.get(&#39;type&#39;, ...]
n27[edge_risk = edge.get(&#39;risk&#39;, ...]
n28[explanation += f&#39; - **攻擊效果**: {self._tr...]
n29[explanation += f&#39; - **路徑風險**: {edge_ris...]
n30[]
n31[explanation += &#39;\n&#39;]
n32{if i == len(path.nodes) - 1}
n33[explanation += f&#39;**步驟 {i + 1}: 攻擊目標...]
n34[explanation += f&#39; - 攻擊者成功到達 {self._get_...]
n35[explanation += &#39; - 可能的後果:\n&#39;]
n36{if &#39;Database&#39; in node_labels}
n37[explanation += &#39; - 竊取、篡改或刪除敏感資料\n&#...]
n38[explanation += &#39; - 獲取使用者憑證和個人資訊\n&#...]
n39[explanation += &#39; - 破壞資料完整性\n&#39;]
n40{if &#39;Credential&#39; in node_labels}
n41[explanation += &#39; - 劫持使用者帳號\n&#39;]
n42[explanation += &#39; - 橫向移動到其他系統\n&#39;]
n43[explanation += &#39; - 持久化存取\n&#39;]
n44{if &#39;InternalNetwork&#39; in node_l...}
n45[explanation += &#39; - 探測內部網路拓撲\n&#39;]
n46[explanation += &#39; - 存取內部服務和 API\n&#39;]
n47[explanation += &#39; - 建立跳板進行進一步攻擊\n&#39;]
n48{if &#39;APIEndpoint&#39; in node_labels}
n49[explanation += &#39; - 未授權存取敏感 API\n&#39;]
n50[explanation += &#39; - 資料洩露或篡改\n&#39;]
n51[explanation += &#39; - 業務邏輯繞過\n&#39;]
n52[]
n53[]
n54[]
n55[]
n56[explanation += &#39;\n&#39;]
n57[]
n58[]
n59[]
n60[]
n61[return explanation]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n60
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n59
n12 -->|Yes| n13
n12 -->|No| n32
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n23
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n30
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n58
n32 -->|Yes| n33
n32 -->|No| n57
n33 --> n34
n34 --> n35
n35 --> n36
n36 -->|Yes| n37
n36 -->|No| n40
n37 --> n38
n38 --> n39
n39 --> n55
n40 -->|Yes| n41
n40 -->|No| n44
n41 --> n42
n42 --> n43
n43 --> n54
n44 -->|Yes| n45
n44 -->|No| n48
n45 --> n46
n46 --> n47
n47 --> n53
n48 -->|Yes| n49
n48 -->|No| n52
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n53
n53 --> n54
n54 --> n55
n55 --> n56
n56 --> n57
n57 --> n58
n58 --> n59
n59 --> n6
n60 --> n61
n61 --> n2
909. integration aiva integration attack path analyzer nlp recommender Function get current time
flowchart TB
n1([開始])
n2([結束])
n3['獲取當前時間字串']
n4[from datetime import datetime]
n5[return datetime.now().strftime('%...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取當前時間字串&#39;]
n4[from datetime import datetime]
n5[return datetime.now().strftime(&#39;%...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
910. integration aiva integration attack path analyzer nlp recommender Function get node description
flowchart TB
n1([開始])
n2([結束])
n3['獲取節點描述']
n4[node_labels = node.get('labels...]
n5[node_type = node_labels[0] if no...]
n6[name = node.get('name', nod...]
n7[type_name = self._node_descripti...]
n8[return f'{type_name}: {name...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取節點描述&#39;]
n4[node_labels = node.get(&#39;labels&#3...]
n5[node_type = node_labels[0] if no...]
n6[name = node.get(&#39;name&#39;, nod...]
n7[type_name = self._node_descripti...]
n8[return f&#39;{type_name}: {name...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
911. integration aiva integration attack path analyzer nlp recommender Function get node type name
flowchart TB
n1([開始])
n2([結束])
n3['獲取節點類型名稱']
n4[node_labels = node.get('labels...]
n5{for label in node_labels}
n6{if label in self._node_descrip...}
n7[return self._node_descriptions[label]]
n8[]
n9[]
n10[return '系統資源']
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取節點類型名稱&#39;]
n4[node_labels = node.get(&#39;labels&#3...]
n5{for label in node_labels}
n6{if label in self._node_descrip...}
n7[return self._node_descriptions[label]]
n8[]
n9[]
n10[return &#39;系統資源&#39;]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
912. integration aiva integration attack path analyzer nlp recommender Function identify quick wins
flowchart TB
n1([開始])
n2([結束])
n3['識別快速修復項目(低工作量、高效益)']
n4[quick_wins = []]
n5[vulnerabilities = [node for node in pa...]
n6{for vuln in vulnerabilities}
n7[vuln_name = vuln.get('name', ...]
n8{if vuln_name == 'XSS'}
n9[quick_wins.append('🚀 部署 Content Security ...]
n10[quick_wins.append('🚀 啟用 HttpOnly 和 Secure...]
n11{if vuln_name == 'SSRF'}
n12[quick_wins.append('🚀 在防火牆層面阻擋內部 IP 存取 ...]
n13[quick_wins.append('🚀 加入雲端元資料端點黑名單 (30...]
n14{if vuln_name in ['IDOR', &...}
n15[quick_wins.append('🚀 在中介軟體層面加入統一授權檢查 (...]
n16[quick_wins.append('🚀 啟用詳細的存取日誌記錄 (1小時...]
n17[]
n18[]
n19[]
n20[]
n21{if len(vulnerabilities) > 0}
n22[quick_wins.append('🚀 部署 WAF 規則阻擋已知攻擊模式 ...]
n23[quick_wins.append('🚀 限制錯誤訊息中的敏感資訊洩露 (...]
n24[]
n25[return list(set(quick_wins))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n20
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n19
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n18
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n6
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;識別快速修復項目(低工作量、高效益)&#39;]
n4[quick_wins = []]
n5[vulnerabilities = [node for node in pa...]
n6{for vuln in vulnerabilities}
n7[vuln_name = vuln.get(&#39;name&#39;, ...]
n8{if vuln_name == &#39;XSS&#39;}
n9[quick_wins.append(&#39;🚀 部署 Content Security ...]
n10[quick_wins.append(&#39;🚀 啟用 HttpOnly 和 Secure...]
n11{if vuln_name == &#39;SSRF&#39;}
n12[quick_wins.append(&#39;🚀 在防火牆層面阻擋內部 IP 存取 ...]
n13[quick_wins.append(&#39;🚀 加入雲端元資料端點黑名單 (30...]
n14{if vuln_name in [&#39;IDOR&#39;, &...}
n15[quick_wins.append(&#39;🚀 在中介軟體層面加入統一授權檢查 (...]
n16[quick_wins.append(&#39;🚀 啟用詳細的存取日誌記錄 (1小時...]
n17[]
n18[]
n19[]
n20[]
n21{if len(vulnerabilities) &gt; 0}
n22[quick_wins.append(&#39;🚀 部署 WAF 規則阻擋已知攻擊模式 &#...]
n23[quick_wins.append(&#39;🚀 限制錯誤訊息中的敏感資訊洩露 (...]
n24[]
n25[return list(set(quick_wins))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n20
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n19
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n18
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n6
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
913. integration aiva integration attack path analyzer nlp recommender Function translate edge type
flowchart TB
n1([開始])
n2([結束])
n3['翻譯邊類型']
n4[translations = {'EXPLOITS': ...]
n5[return translations.get(edge_type, ed...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;翻譯邊類型&#39;]
n4[translations = {&#39;EXPLOITS&#39;: ...]
n5[return translations.get(edge_type, ed...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
914. integration aiva integration attack path analyzer nlp recommender Function analyze and recommend
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析攻擊路徑並生成推薦\n\n Args:\n ...]
n4[recommendations = []]
n5{for path in paths[:top_n]}
n6[priority_score = self._calculate_prio...]
n7[risk_level = self._determine_risk...]
n8[executive_summary = self._generate_execu...]
n9[technical_explanation = self._generate_techn...]
n10[business_impact = self._generate_busin...]
n11[remediation_steps = self._generate_remed...]
n12[quick_wins = self._identify_quick...]
n13[affected_assets = self._extract_affect...]
n14[estimated_effort = self._estimate_effor...]
n15[risk_reduction = self._estimate_risk_...]
n16[recommendations.append(PathRecommendation(path_id...]
n17[]
n18[recommendations.sort(key=lambda x: x.priority_scor...]
n19[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n5
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析攻擊路徑並生成推薦\n\n Args:\n ...]
n4[recommendations = []]
n5{for path in paths[:top_n]}
n6[priority_score = self._calculate_prio...]
n7[risk_level = self._determine_risk...]
n8[executive_summary = self._generate_execu...]
n9[technical_explanation = self._generate_techn...]
n10[business_impact = self._generate_busin...]
n11[remediation_steps = self._generate_remed...]
n12[quick_wins = self._identify_quick...]
n13[affected_assets = self._extract_affect...]
n14[estimated_effort = self._estimate_effor...]
n15[risk_reduction = self._estimate_risk_...]
n16[recommendations.append(PathRecommendation(path_id...]
n17[]
n18[recommendations.sort(key=lambda x: x.priority_scor...]
n19[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n17
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n5
n17 --> n18
n18 --> n19
n19 --> n2
915. integration aiva integration attack path analyzer nlp recommender Function generate report
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成完整的推薦報告\n\n Args:\n ...]
n4[report = '# 攻擊路徑分析與修復建議報告\n\n...]
n5[report += f'**生成時間**: {self._get_current...]
n6[report += '---\n\n']
n7[report += '## 📊 執行摘要\n\n']
n8[report += f'本次分析發現 **{len(recommenda...]
n9[risk_counts = dict.fromkeys(RiskLe...]
n10{for rec in recommendations}
n11[risk_counts[rec.risk_level] += 1]
n12[]
n13[report += '### 風險等級分布\n\n&...]
n14[report += f'- 🔴 **CRITICAL**: {risk_coun...]
n15[report += f'- 🟠 **HIGH**: {risk_counts...]
n16[report += f'- 🟡 **MEDIUM**: {risk_counts...]
n17[report += f'- 🟢 **LOW**: {risk_counts ...]
n18{if risk_counts[RiskLevel.CRITI...}
n19[report += '### ⚠️ 緊急建議\n\n&...]
n20[report += f'發現 {risk_counts[RiskLeve...]
n21[report += '建議立即召開緊急會議,在 24 小時內開始修復工作。\n\n&...]
n22[]
n23[report += '---\n\n']
n24[report += '## 🎯 詳細推薦\n\n']
n25{for (i, rec) in enumerate(recomme...}
n26[report += f'### 路徑 {i}:...]
n27[report += rec.executive_summary + '\n\n&&...]
n28[report += rec.technical_explanation + '\n\n&a...]
n29[report += rec.business_impact + '\n\n&...]
n30{if rec.quick_wins}
n31[report += '### ⚡ 快速修復建議\n\n&&...]
n32{for quick_win in rec.quick_wins}
n33[report += f'- {quick_win}\n&...]
n34[]
n35[report += '\n']
n36[]
n37[report += '### 🔧 詳細修復步驟\n\n&&...]
n38{for (j, step) in enumerate(rec.rem...}
n39[report += f'{j}. {step}\n...]
n40[]
n41{if rec.affected_assets}
n42[report += '### 📦 受影響資產\n\n&...]
n43{for asset in rec.affected_assets}
n44[report += f'- `{asset}`\n']
n45[]
n46[report += '\n']
n47[]
n48[report += '### 📈 修復評估\n\n&...]
n49[report += f'- **預估工作量**: {rec.estimated_...]
n50[report += f'- **預估風險降低**: {rec.estimated...]
n51[report += f'- **優先級分數**: {rec.priority_s...]
n52[report += '---\n\n']
n53[]
n54[report += '## 📝 總結與後續行動\n\n']
n55[report += '### 建議的行動優先順序\n\n&...]
n56[critical_recs = [r for r in recommen...]
n57[high_recs = [r for r in recommen...]
n58{if critical_recs}
n59[report += '**立即行動 (24小時內)**:\n&...]
n60{for rec in critical_recs[:3]}
n61[report += f'- 修復路徑: {rec.path_id}\n...]
n62[]
n63[report += '\n']
n64[]
n65{if high_recs}
n66[report += '**短期行動 (1週內)**:\n&#...]
n67{for rec in high_recs[:3]}
n68[report += f'- 修復路徑: {rec.path_id}\n...]
n69[]
n70[report += '\n']
n71[]
n72[report += '**中長期行動**:\n']
n73[report += '- 建立持續的漏洞掃描和攻擊路徑分析機制\n']
n74[report += '- 加強安全開發培訓\n']
n75[report += '- 實施安全左移 (Shift-Left Security&...]
n76[report += '- 定期進行紅隊演練\n\n']
n77[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n22
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n53
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n36
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n34
n33 --> n32
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 -->|Yes| n39
n38 -->|No| n40
n39 --> n38
n40 --> n41
n41 -->|Yes| n42
n41 -->|No| n47
n42 --> n43
n43 -->|Yes| n44
n43 -->|No| n45
n44 --> n43
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n25
n53 --> n54
n54 --> n55
n55 --> n56
n56 --> n57
n57 --> n58
n58 -->|Yes| n59
n58 -->|No| n64
n59 --> n60
n60 -->|Yes| n61
n60 -->|No| n62
n61 --> n60
n62 --> n63
n63 --> n64
n64 --> n65
n65 -->|Yes| n66
n65 -->|No| n71
n66 --> n67
n67 -->|Yes| n68
n67 -->|No| n69
n68 --> n67
n69 --> n70
n70 --> n71
n71 --> n72
n72 --> n73
n73 --> n74
n74 --> n75
n75 --> n76
n76 --> n77
n77 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成完整的推薦報告\n\n Args:\n ...]
n4[report = &#39;# 攻擊路徑分析與修復建議報告\n\n...]
n5[report += f&#39;**生成時間**: {self._get_current...]
n6[report += &#39;---\n\n&#39;]
n7[report += &#39;## 📊 執行摘要\n\n&#39;]
n8[report += f&#39;本次分析發現 **{len(recommenda...]
n9[risk_counts = dict.fromkeys(RiskLe...]
n10{for rec in recommendations}
n11[risk_counts[rec.risk_level] += 1]
n12[]
n13[report += &#39;### 風險等級分布\n\n&...]
n14[report += f&#39;- 🔴 **CRITICAL**: {risk_coun...]
n15[report += f&#39;- 🟠 **HIGH**: {risk_counts&#...]
n16[report += f&#39;- 🟡 **MEDIUM**: {risk_counts...]
n17[report += f&#39;- 🟢 **LOW**: {risk_counts	...]
n18{if risk_counts[RiskLevel.CRITI...}
n19[report += &#39;### ⚠️ 緊急建議\n\n&&#...]
n20[report += f&#39;發現 {risk_counts[RiskLeve...]
n21[report += &#39;建議立即召開緊急會議,在 24 小時內開始修復工作。\n\n&...]
n22[]
n23[report += &#39;---\n\n&#39;]
n24[report += &#39;## 🎯 詳細推薦\n\n&#39;]
n25{for (i, rec) in enumerate(recomme...}
n26[report += f&#39;### 路徑 {i}:...]
n27[report += rec.executive_summary + &#39;\n\n&&...]
n28[report += rec.technical_explanation + &#39;\n\n&a...]
n29[report += rec.business_impact + &#39;\n\n&...]
n30{if rec.quick_wins}
n31[report += &#39;### ⚡ 快速修復建議\n\n&&...]
n32{for quick_win in rec.quick_wins}
n33[report += f&#39;- {quick_win}\n&...]
n34[]
n35[report += &#39;\n&#39;]
n36[]
n37[report += &#39;### 🔧 詳細修復步驟\n\n&&...]
n38{for (j, step) in enumerate(rec.rem...}
n39[report += f&#39;{j}. {step}\n...]
n40[]
n41{if rec.affected_assets}
n42[report += &#39;### 📦 受影響資產\n\n&&#...]
n43{for asset in rec.affected_assets}
n44[report += f&#39;- `{asset}`\n&#39;]
n45[]
n46[report += &#39;\n&#39;]
n47[]
n48[report += &#39;### 📈 修復評估\n\n&...]
n49[report += f&#39;- **預估工作量**: {rec.estimated_...]
n50[report += f&#39;- **預估風險降低**: {rec.estimated...]
n51[report += f&#39;- **優先級分數**: {rec.priority_s...]
n52[report += &#39;---\n\n&#39;]
n53[]
n54[report += &#39;## 📝 總結與後續行動\n\n&#39;]
n55[report += &#39;### 建議的行動優先順序\n\n&...]
n56[critical_recs = [r for r in recommen...]
n57[high_recs = [r for r in recommen...]
n58{if critical_recs}
n59[report += &#39;**立即行動 (24小時內)**:\n&&#...]
n60{for rec in critical_recs[:3]}
n61[report += f&#39;- 修復路徑: {rec.path_id}\n...]
n62[]
n63[report += &#39;\n&#39;]
n64[]
n65{if high_recs}
n66[report += &#39;**短期行動 (1週內)**:\n&#...]
n67{for rec in high_recs[:3]}
n68[report += f&#39;- 修復路徑: {rec.path_id}\n...]
n69[]
n70[report += &#39;\n&#39;]
n71[]
n72[report += &#39;**中長期行動**:\n&#39;]
n73[report += &#39;- 建立持續的漏洞掃描和攻擊路徑分析機制\n&#39;]
n74[report += &#39;- 加強安全開發培訓\n&#39;]
n75[report += &#39;- 實施安全左移 (Shift-Left Security&...]
n76[report += &#39;- 定期進行紅隊演練\n\n&#39;]
n77[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n22
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n53
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n36
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n34
n33 --> n32
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n38
n38 -->|Yes| n39
n38 -->|No| n40
n39 --> n38
n40 --> n41
n41 -->|Yes| n42
n41 -->|No| n47
n42 --> n43
n43 -->|Yes| n44
n43 -->|No| n45
n44 --> n43
n45 --> n46
n46 --> n47
n47 --> n48
n48 --> n49
n49 --> n50
n50 --> n51
n51 --> n52
n52 --> n25
n53 --> n54
n54 --> n55
n55 --> n56
n56 --> n57
n57 --> n58
n58 -->|Yes| n59
n58 -->|No| n64
n59 --> n60
n60 -->|Yes| n61
n60 -->|No| n62
n61 --> n60
n62 --> n63
n63 --> n64
n64 --> n65
n65 -->|Yes| n66
n65 -->|No| n71
n66 --> n67
n67 -->|Yes| n68
n67 -->|No| n69
n68 --> n67
n69 --> n70
n70 --> n71
n71 --> n72
n72 --> n73
n73 --> n74
n74 --> n75
n75 --> n76
n76 --> n77
n77 --> n2
916. integration aiva integration attack path analyzer visualizer Function get node shape
flowchart TB
n1([開始])
n2([結束])
n3['取得 Mermaid 節點形狀']
n4[shapes = {'Attacker': &&...]
n5[return shapes.get(node_type, '[Unknow...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取得 Mermaid 節點形狀&#39;]
n4[shapes = {&#39;Attacker&#39;: &&...]
n5[return shapes.get(node_type, &#39;[Unknow...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
917. integration aiva integration attack path analyzer visualizer Function to cytoscape json
flowchart TB
n1([開始])
n2([結束])
n3['\n 轉換為 Cytoscape JSON 格式(用於互動式視覺化)\n\...]
n4[elements = {'nodes': [...]
n5[node_ids = set()]
n6{for (path_idx, path) in enumerate(paths)}
n7{for (i, node) in enumerate(path.no...}
n8[node_id = node.get('id', f&am...]
n9{if node_id not in node_ids}
n10[node_data = {'id': node_id, ...]
n11[elements['nodes'].append&...]
n12[node_ids.add(node_id)]
n13[]
n14{if i > 0}
n15[prev_node = path.nodes[i - 1]]
n16[prev_id = prev_node.get('id',...]
n17[edge_data = {'id': f&...]
n18[elements['edges'].append&...]
n19[]
n20[]
n21[]
n22[return json.dumps(elements, indent=2)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n21
n7 -->|Yes| n8
n7 -->|No| n20
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n19
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n7
n20 --> n6
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 轉換為 Cytoscape JSON 格式(用於互動式視覺化)\n\...]
n4[elements = {&#39;nodes&#39;: [&#...]
n5[node_ids = set()]
n6{for (path_idx, path) in enumerate(paths)}
n7{for (i, node) in enumerate(path.no...}
n8[node_id = node.get(&#39;id&#39;, f&am...]
n9{if node_id not in node_ids}
n10[node_data = {&#39;id&#39;: node_id, ...]
n11[elements[&#39;nodes&#39;].append&...]
n12[node_ids.add(node_id)]
n13[]
n14{if i &gt; 0}
n15[prev_node = path.nodes[i - 1]]
n16[prev_id = prev_node.get(&#39;id&#39;,...]
n17[edge_data = {&#39;id&#39;: f&...]
n18[elements[&#39;edges&#39;].append&...]
n19[]
n20[]
n21[]
n22[return json.dumps(elements, indent=2)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n21
n7 -->|Yes| n8
n7 -->|No| n20
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n19
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n7
n20 --> n6
n21 --> n22
n22 --> n2
918. integration aiva integration attack path analyzer visualizer Function to html
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成 HTML 互動式視覺化頁面\n\n Args:\...]
n4[cytoscape_data = AttackPathVisualizer...]
n5[html_template = f"""\n<...]
n6[with open(outp...]
n7[f.write(html_template)]
n8[print(f'HTML visualization saved to {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成 HTML 互動式視覺化頁面\n\n Args:\...]
n4[cytoscape_data = AttackPathVisualizer...]
n5[html_template = f&quot;&quot;&quot;\n&lt;...]
n6[with open(outp...]
n7[f.write(html_template)]
n8[print(f&#39;HTML visualization saved to {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
919. integration aiva integration attack path analyzer visualizer Function to mermaid
flowchart TB
n1([開始])
n2([結束])
n3['\n 轉換為 Mermaid 流程圖\n\n Args:\n...]
n4[lines = ['```mermaid', &&...]
n5[node_ids = set()]
n6[edges = []]
n7{for (_, path) in enumerate(paths)}
n8{for (i, node) in enumerate(path.no...}
n9[node_id = node.get('id', f&am...]
n10[node_type = list(node.get('label...]
n11[safe_id = node_id.replace('-'...]
n12{if safe_id not in node_ids}
n13[shape = AttackPathVisualizer...]
n14[lines.append(f' {safe_id}...]
n15[node_ids.add(safe_id)]
n16[]
n17{if i > 0}
n18[prev_node = path.nodes[i - 1]]
n19[prev_id = prev_node.get('id',...]
n20{if i - 1 < len(path.edges)}
n21[edge = path.edges[i - 1]]
n22[edge_type = edge.get('type', ...]
n23[edge_label = f'|{edge_type}...]
n24[edge_label = '']
n25[]
n26[edges.append(f' {prev_id} --...]
n27[]
n28[]
n29[]
n30[lines.extend(edges)]
n31[lines.extend(['', &...]
n32[lines.append('```')]
n33[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n29
n8 -->|Yes| n9
n8 -->|No| n28
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n27
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n24
n21 --> n22
n22 --> n23
n23 --> n25
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n8
n28 --> n7
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 轉換為 Mermaid 流程圖\n\n Args:\n...]
n4[lines = [&#39;```mermaid&#39;, &&...]
n5[node_ids = set()]
n6[edges = []]
n7{for (_, path) in enumerate(paths)}
n8{for (i, node) in enumerate(path.no...}
n9[node_id = node.get(&#39;id&#39;, f&am...]
n10[node_type = list(node.get(&#39;label...]
n11[safe_id = node_id.replace(&#39;-&#39;...]
n12{if safe_id not in node_ids}
n13[shape = AttackPathVisualizer...]
n14[lines.append(f&#39; {safe_id}...]
n15[node_ids.add(safe_id)]
n16[]
n17{if i &gt; 0}
n18[prev_node = path.nodes[i - 1]]
n19[prev_id = prev_node.get(&#39;id&#39;,...]
n20{if i - 1 &lt; len(path.edges)}
n21[edge = path.edges[i - 1]]
n22[edge_type = edge.get(&#39;type&#39;, ...]
n23[edge_label = f&#39;|{edge_type}...]
n24[edge_label = &#39;&#39;]
n25[]
n26[edges.append(f&#39; {prev_id} --...]
n27[]
n28[]
n29[]
n30[lines.extend(edges)]
n31[lines.extend([&#39;&#39;, &&#...]
n32[lines.append(&#39;```&#39;)]
n33[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n29
n8 -->|Yes| n9
n8 -->|No| n28
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n27
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n24
n21 --> n22
n22 --> n23
n23 --> n25
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n8
n28 --> n7
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
920. integration aiva integration config template config template manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._templates: dict[str, dict[str, Any]]...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._templates: dict[str, dict[str, Any]]...]
n1 --> n3
n3 --> n2
921. integration aiva integration config template config template manager Function create custom template
flowchart TB
n1([開始])
n2([結束])
n3['創建自定義模板']
n4[self._templates[name] = config]
n5[logger.info(f'Created custom template: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建自定義模板&#39;]
n4[self._templates[name] = config]
n5[logger.info(f&#39;Created custom template: &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
922. integration aiva integration config template config template manager Function get template
flowchart TB
n1([開始])
n2([結束])
n3['獲取配置模板']
n4[return self._templates.get(template_n...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取配置模板&#39;]
n4[return self._templates.get(template_n...]
n1 --> n3
n3 --> n4
n4 --> n2
923. integration aiva integration config template config template manager Function list templates
flowchart TB
n1([開始])
n2([結束])
n3['列出可用模板']
n4[return list(self._templates.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;列出可用模板&#39;]
n4[return list(self._templates.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
924. integration aiva integration examples enhanced attack path demo Function demo basic attack path analysis
flowchart TB
n1([開始])
n2([結束])
n3['基礎攻擊路徑分析示範']
n4[logger.info('=== 基礎攻擊路徑分析 ==='...]
n5[engine = AttackPathEngine(neo...]
n6[try]
n7[engine.clear_graph()]
n8[engine.initialize_graph()]
n9[assets = [Asset(asset_id='web...]
n10[findings = [FindingPayload(find...]
n11{for asset in assets}
n12[engine.add_asset(asset)]
n13[logger.info(f'Added asset: {asset.as...]
n14[]
n15{for finding in findings}
n16[engine.add_finding(finding)]
n17[logger.info(f'Added finding: {findin...]
n18[]
n19[logger.info('\n=== 尋找到資料庫的攻擊路徑 ===&...]
n20[db_paths = engine.find_attack_p...]
n21{for path in db_paths}
n22[logger.info(f'\n路徑 {path.path_id...]
n23[logger.info(f' 風險分數: {path.total_ri...]
n24[logger.info(f' 路徑長度: {path.length...]
n25[logger.info(f' 描述: {path.descriptio...]
n26[]
n27[logger.info('\n=== 尋找到內部網路的攻擊路徑 ===&&...]
n28[internal_paths = engine.find_attack_p...]
n29{for path in internal_paths}
n30[logger.info(f'\n路徑 {path.path_id...]
n31[logger.info(f' 風險分數: {path.total_ri...]
n32[logger.info(f' 路徑長度: {path.length...]
n33[]
n34[return db_paths + internal_paths]
n35[]
n36[finally]
n37[engine.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n11
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n26
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n21
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n33
n30 --> n31
n31 --> n32
n32 --> n29
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;基礎攻擊路徑分析示範&#39;]
n4[logger.info(&#39;=== 基礎攻擊路徑分析 ===&#39...]
n5[engine = AttackPathEngine(neo...]
n6[try]
n7[engine.clear_graph()]
n8[engine.initialize_graph()]
n9[assets = [Asset(asset_id=&#39;web...]
n10[findings = [FindingPayload(find...]
n11{for asset in assets}
n12[engine.add_asset(asset)]
n13[logger.info(f&#39;Added asset: {asset.as...]
n14[]
n15{for finding in findings}
n16[engine.add_finding(finding)]
n17[logger.info(f&#39;Added finding: {findin...]
n18[]
n19[logger.info(&#39;\n=== 尋找到資料庫的攻擊路徑 ===&&#...]
n20[db_paths = engine.find_attack_p...]
n21{for path in db_paths}
n22[logger.info(f&#39;\n路徑 {path.path_id...]
n23[logger.info(f&#39; 風險分數: {path.total_ri...]
n24[logger.info(f&#39; 路徑長度: {path.length&#...]
n25[logger.info(f&#39; 描述: {path.descriptio...]
n26[]
n27[logger.info(&#39;\n=== 尋找到內部網路的攻擊路徑 ===&&...]
n28[internal_paths = engine.find_attack_p...]
n29{for path in internal_paths}
n30[logger.info(f&#39;\n路徑 {path.path_id...]
n31[logger.info(f&#39; 風險分數: {path.total_ri...]
n32[logger.info(f&#39; 路徑長度: {path.length&#...]
n33[]
n34[return db_paths + internal_paths]
n35[]
n36[finally]
n37[engine.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n11
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n15
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n26
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n21
n26 --> n27
n27 --> n28
n28 --> n29
n29 -->|Yes| n30
n29 -->|No| n33
n30 --> n31
n31 --> n32
n32 --> n29
n33 --> n34
n34 --> n35
n35 --> n36
n36 --> n37
n37 --> n2
925. integration aiva integration examples enhanced attack path demo Function demo critical nodes
flowchart TB
n1([開始])
n2([結束])
n3['關鍵節點分析示範']
n4[logger.info('\n=== 關鍵節點分析 ==='...]
n5[engine = AttackPathEngine(neo...]
n6[try]
n7[critical_nodes = engine.find_critical...]
n8[logger.info(f'\n發現 {len(critical...]
n9{for (i, node) in enumerate(critica...}
n10[node_name = node.get('name', ...]
n11[node_degree = node.get('degree...]
n12[node_labels = node.get('labels...]
n13[logger.info(f'\n{i}. {node...]
n14[logger.info(f" 類型: {', &a...]
n15[logger.info(f' 連接度: {node_degree...]
n16{if node_degree >= 3}
n17[logger.info(' ⚠️ 高連接度節點,建議加強監控和防護&&...]
n18[]
n19[]
n20[]
n21[finally]
n22[engine.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n19
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n9
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;關鍵節點分析示範&#39;]
n4[logger.info(&#39;\n=== 關鍵節點分析 ===&#39...]
n5[engine = AttackPathEngine(neo...]
n6[try]
n7[critical_nodes = engine.find_critical...]
n8[logger.info(f&#39;\n發現 {len(critical...]
n9{for (i, node) in enumerate(critica...}
n10[node_name = node.get(&#39;name&#39;, ...]
n11[node_degree = node.get(&#39;degree&#3...]
n12[node_labels = node.get(&#39;labels&#3...]
n13[logger.info(f&#39;\n{i}. {node...]
n14[logger.info(f&quot; 類型: {&#39;, &a...]
n15[logger.info(f&#39; 連接度: {node_degree&#...]
n16{if node_degree &gt;= 3}
n17[logger.info(&#39; ⚠️ 高連接度節點,建議加強監控和防護&&...]
n18[]
n19[]
n20[]
n21[finally]
n22[engine.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n19
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n9
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
926. integration aiva integration examples enhanced attack path demo Function demo generate full report
flowchart TB
n1([開始])
n2([結束])
n3['生成完整報告示範']
n4[logger.info('\n=== 生成完整報告 ==='...]
n5[recommender = AttackPathNLPRecomme...]
n6[report = recommender.generate...]
n7[report_path = Path('_out/attack_pa...]
n8[report_path.parent.mkdir(parents=True, exist_ok=Tr...]
n9[with open(repo...]
n10[f.write(report)]
n11[logger.info(f'報告已保存至: {report_path...]
n12[logger.info('\n報告預覽:')]
n13[logger.info('=' * 80)]
n14[logger.info(report[:1000])]
n15[logger.info('...')]
n16[logger.info('=' * 80)]
n17[return report_path]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成完整報告示範&#39;]
n4[logger.info(&#39;\n=== 生成完整報告 ===&#39...]
n5[recommender = AttackPathNLPRecomme...]
n6[report = recommender.generate...]
n7[report_path = Path(&#39;_out/attack_pa...]
n8[report_path.parent.mkdir(parents=True, exist_ok=Tr...]
n9[with open(repo...]
n10[f.write(report)]
n11[logger.info(f&#39;報告已保存至: {report_path&#...]
n12[logger.info(&#39;\n報告預覽:&#39;)]
n13[logger.info(&#39;=&#39; * 80)]
n14[logger.info(report[:1000])]
n15[logger.info(&#39;...&#39;)]
n16[logger.info(&#39;=&#39; * 80)]
n17[return report_path]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
927. integration aiva integration examples enhanced attack path demo Function demo nlp recommendations
flowchart TB
n1([開始])
n2([結束])
n3['自然語言推薦系統示範']
n4[logger.info('\n=== 生成自然語言推薦 ===&#...]
n5[recommender = AttackPathNLPRecomme...]
n6[recommendations = recommender.analyze_...]
n7{for (i, rec) in enumerate(recomme...}
n8[logger.info(f"\n{'=&...]
n9[logger.info(f'推薦 {i}/{len&...]
n10[logger.info(f"{'=&#...]
n11[logger.info(f'路徑 ID: {rec.path_id...]
n12[logger.info(f'風險等級: {rec.risk_level....]
n13[logger.info(f'優先級分數: {rec.priority_s...]
n14[logger.info(f'\n{rec.executive_summa...]
n15[logger.info(f'\n預估工作量: {rec.estimate...]
n16[logger.info(f'預估風險降低: {rec.estimated...]
n17{if rec.quick_wins}
n18[logger.info('\n快速修復建議:')]
n19{for quick_win in rec.quick_wins}
n20[logger.info(f' {quick_win}&...]
n21[]
n22[]
n23[]
n24[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n23
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n19
n21 --> n22
n22 --> n7
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;自然語言推薦系統示範&#39;]
n4[logger.info(&#39;\n=== 生成自然語言推薦 ===&#...]
n5[recommender = AttackPathNLPRecomme...]
n6[recommendations = recommender.analyze_...]
n7{for (i, rec) in enumerate(recomme...}
n8[logger.info(f&quot;\n{&#39;=&...]
n9[logger.info(f&#39;推薦 {i}/{len&...]
n10[logger.info(f&quot;{&#39;=&#...]
n11[logger.info(f&#39;路徑 ID: {rec.path_id...]
n12[logger.info(f&#39;風險等級: {rec.risk_level....]
n13[logger.info(f&#39;優先級分數: {rec.priority_s...]
n14[logger.info(f&#39;\n{rec.executive_summa...]
n15[logger.info(f&#39;\n預估工作量: {rec.estimate...]
n16[logger.info(f&#39;預估風險降低: {rec.estimated...]
n17{if rec.quick_wins}
n18[logger.info(&#39;\n快速修復建議:&#39;)]
n19{for quick_win in rec.quick_wins}
n20[logger.info(f&#39; {quick_win}&...]
n21[]
n22[]
n23[]
n24[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n23
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n19
n21 --> n22
n22 --> n7
n23 --> n24
n24 --> n2
928. integration aiva integration examples enhanced attack path demo Function demo vulnerability statistics
flowchart TB
n1([開始])
n2([結束])
n3['漏洞統計示範']
n4[logger.info('\n=== 漏洞統計 ==='&...]
n5[engine = AttackPathEngine(neo...]
n6[try]
n7[stats = engine.get_vulnerabi...]
n8[logger.info(f"\n總漏洞數: {stats[&&...]
n9[logger.info('\n按嚴重程度分布:')]
n10{for (severity, count) in sorted(stats[&am...}
n11[percentage = count / stats['total...]
n12[bar = '█' * int(percentage...]
n13[logger.info(f' {severity:12s}:...]
n14[]
n15[]
n16[finally]
n17[engine.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n10
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;漏洞統計示範&#39;]
n4[logger.info(&#39;\n=== 漏洞統計 ===&#39;&...]
n5[engine = AttackPathEngine(neo...]
n6[try]
n7[stats = engine.get_vulnerabi...]
n8[logger.info(f&quot;\n總漏洞數: {stats[&&...]
n9[logger.info(&#39;\n按嚴重程度分布:&#39;)]
n10{for (severity, count) in sorted(stats[&am...}
n11[percentage = count / stats[&#39;total...]
n12[bar = &#39;█&#39; * int(percentage...]
n13[logger.info(f&#39; {severity:12s}:...]
n14[]
n15[]
n16[finally]
n17[engine.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n10
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
929. integration aiva integration examples enhanced attack path demo Function main
flowchart TB
n1([開始])
n2([結束])
n3['主示範函數']
n4[logger.info('=' * 80)]
n5[logger.info('攻擊路徑分析與自然語言推薦系統 - 完整示範&&...]
n6[logger.info('=' * 80)]
n7[try]
n8[paths = demo_basic_attack_pa...]
n9{if not paths}
n10[logger.warning('未發現任何攻擊路徑,請檢查 Neo4j 連線和資料...]
n11[return]
n12[]
n13[recommendations = demo_nlp_recommendat...]
n14[report_path = demo_generate_full_r...]
n15[demo_critical_nodes()]
n16[demo_vulnerability_statistics()]
n17[logger.info('\n' + &#...]
n18[logger.info('示範完成!')]
n19[logger.info(f'完整報告已保存至: {report_path...]
n20[logger.info('=' * 80)]
n21[]
n22[except Exception]
n23[logger.error(f'示範執行失敗: {e}&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n22
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
n22 --> n23
n23 --> n21
flowchart TB
n1([開始])
n2([結束])
n3[&#39;主示範函數&#39;]
n4[logger.info(&#39;=&#39; * 80)]
n5[logger.info(&#39;攻擊路徑分析與自然語言推薦系統 - 完整示範&&...]
n6[logger.info(&#39;=&#39; * 80)]
n7[try]
n8[paths = demo_basic_attack_pa...]
n9{if not paths}
n10[logger.warning(&#39;未發現任何攻擊路徑,請檢查 Neo4j 連線和資料...]
n11[return]
n12[]
n13[recommendations = demo_nlp_recommendat...]
n14[report_path = demo_generate_full_r...]
n15[demo_critical_nodes()]
n16[demo_vulnerability_statistics()]
n17[logger.info(&#39;\n&#39; + &#...]
n18[logger.info(&#39;示範完成!&#39;)]
n19[logger.info(f&#39;完整報告已保存至: {report_path...]
n20[logger.info(&#39;=&#39; * 80)]
n21[]
n22[except Exception]
n23[logger.error(f&#39;示範執行失敗: {e}&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n22
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
n22 --> n23
n23 --> n21
930. integration aiva integration examples enhanced risk assessment demo Function example basic assessment
flowchart TB
n1([開始])
n2([結束])
n3['基礎風險評估範例']
n4[engine = EnhancedRiskAssessme...]
n5[findings = [{'vulnerability_typ...]
n6[context = {'environment': &a...]
n7[result = engine.assess_risk(f...]
n8[print('=' * 80)]
n9[print('基礎風險評估')]
n10[print('=' * 80)]
n11[print(f"總體風險分數: {result[...]
n12[print(f"技術風險分數: {result[...]
n13[print(f"業務風險分數: {result[...]
n14[print(f"風險等級: {result['...]
n15[print(f"\n嚴重程度分布: {result[&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;基礎風險評估範例&#39;]
n4[engine = EnhancedRiskAssessme...]
n5[findings = [{&#39;vulnerability_typ...]
n6[context = {&#39;environment&#39;: &a...]
n7[result = engine.assess_risk(f...]
n8[print(&#39;=&#39; * 80)]
n9[print(&#39;基礎風險評估&#39;)]
n10[print(&#39;=&#39; * 80)]
n11[print(f&quot;總體風險分數: {result[&#3...]
n12[print(f&quot;技術風險分數: {result[&#3...]
n13[print(f&quot;業務風險分數: {result[&#3...]
n14[print(f&quot;風險等級: {result[&#39;...]
n15[print(f&quot;\n嚴重程度分布: {result[&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
931. integration aiva integration examples enhanced risk assessment demo Function example comparison
flowchart TB
n1([開始])
n2([結束])
n3['對比不同上下文的風險評估']
n4[engine = EnhancedRiskAssessme...]
n5[findings = [{'vulnerability_typ...]
n6[context_dev = {'environment'...]
n7[context_prod = {'environment'...]
n8[result_dev = engine.assess_risk(f...]
n9[result_prod = engine.assess_risk(f...]
n10[print('\n' + '=&a...]
n11[print('上下文對風險評估的影響對比')]
n12[print('=' * 80)]
n13[print('相同漏洞: SQL Injection (HIGH)...]
n14[print('\n開發環境 (非關鍵):'...]
n15[print(f" 業務風險分數: {result_dev[&...]
n16[print(f" 風險等級: {result_dev[&...]
n17[print(f" 上下文乘數: x{result_dev[&...]
n18[print('\n生產環境 (關鍵):'&...]
n19[print(f" 業務風險分數: {result_prod[&...]
n20[print(f" 風險等級: {result_prod[&&...]
n21[print(f" 上下文乘數: x{result_prod[&...]
n22[risk_multiplier = result_prod['busines...]
n23[print(f'\n風險放大倍數: {risk_multiplier:....]
n24[print('💡 相同的技術漏洞在不同業務上下文中,風險評估可能相差數倍!&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;對比不同上下文的風險評估&#39;]
n4[engine = EnhancedRiskAssessme...]
n5[findings = [{&#39;vulnerability_typ...]
n6[context_dev = {&#39;environment&#39;...]
n7[context_prod = {&#39;environment&#39...]
n8[result_dev = engine.assess_risk(f...]
n9[result_prod = engine.assess_risk(f...]
n10[print(&#39;\n&#39; + &#39;=&a...]
n11[print(&#39;上下文對風險評估的影響對比&#39;)]
n12[print(&#39;=&#39; * 80)]
n13[print(&#39;相同漏洞: SQL Injection (HIGH)...]
n14[print(&#39;\n開發環境 (非關鍵):&#39;...]
n15[print(f&quot; 業務風險分數: {result_dev[&...]
n16[print(f&quot; 風險等級: {result_dev[&&#...]
n17[print(f&quot; 上下文乘數: x{result_dev[&...]
n18[print(&#39;\n生產環境 (關鍵):&#39;&...]
n19[print(f&quot; 業務風險分數: {result_prod[&...]
n20[print(f&quot; 風險等級: {result_prod[&&...]
n21[print(f&quot; 上下文乘數: x{result_prod[&...]
n22[risk_multiplier = result_prod[&#39;busines...]
n23[print(f&#39;\n風險放大倍數: {risk_multiplier:....]
n24[print(&#39;💡 相同的技術漏洞在不同業務上下文中,風險評估可能相差數倍!&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
932. integration aiva integration examples enhanced risk assessment demo Function example production critical asset
flowchart TB
n1([開始])
n2([結束])
n3['生產環境關鍵資產的風險評估']
n4[engine = EnhancedRiskAssessme...]
n5[findings = [{'vulnerability_typ...]
n6[context = {'environment': &a...]
n7[result = engine.assess_risk(f...]
n8[print('\n' + '=&a...]
n9[print('生產環境關鍵資產風險評估')]
n10[print('=' * 80)]
n11[print(f"總體風險分數: {result[...]
n12[print(f"技術風險分數: {result[...]
n13[print(f"業務風險分數: {result[...]
n14[print(f"風險等級: {result['...]
n15[print('\n上下文乘數:')]
n16[context_info = result['context...]
n17[print(f" 環境: {context_info[&...]
n18[print(f" 業務重要性: {context_info[&...]
n19[print(f" 資料敏感度: {context_info[&...]
n20[print(f" 網路暴露: {context_info[&...]
n21[print(f" 合規要求: {context_info[&...]
n22[print(f" 總體乘數: x{context_info[&...]
n23[print('\n業務影響估算:')]
n24[impact = result['business_imp...]
n25[print(f" 預估財務影響: ${impact[&...]
n26[print(f" 潛在受影響使用者: {impact[&...]
n27[print(f" 業務中斷風險: {impact[&#...]
n28[print(f" 名譽風險: {impact[...]
n29[print('\n優先級建議:')]
n30{for (i, recommendation) in enumerate(result...}
n31[print(f' {i}. {recommenda...]
n32[]
n33[print('\n最高優先級漏洞:')]
n34{for (i, finding) in enumerate(result[...}
n35[print(f" {i}. {finding.get...]
n36[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n32
n31 --> n30
n32 --> n33
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n34
n36 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生產環境關鍵資產的風險評估&#39;]
n4[engine = EnhancedRiskAssessme...]
n5[findings = [{&#39;vulnerability_typ...]
n6[context = {&#39;environment&#39;: &a...]
n7[result = engine.assess_risk(f...]
n8[print(&#39;\n&#39; + &#39;=&a...]
n9[print(&#39;生產環境關鍵資產風險評估&#39;)]
n10[print(&#39;=&#39; * 80)]
n11[print(f&quot;總體風險分數: {result[&#3...]
n12[print(f&quot;技術風險分數: {result[&#3...]
n13[print(f&quot;業務風險分數: {result[&#3...]
n14[print(f&quot;風險等級: {result[&#39;...]
n15[print(&#39;\n上下文乘數:&#39;)]
n16[context_info = result[&#39;context&#3...]
n17[print(f&quot; 環境: {context_info[&&#...]
n18[print(f&quot; 業務重要性: {context_info[&...]
n19[print(f&quot; 資料敏感度: {context_info[&...]
n20[print(f&quot; 網路暴露: {context_info[&...]
n21[print(f&quot; 合規要求: {context_info[&...]
n22[print(f&quot; 總體乘數: x{context_info[&...]
n23[print(&#39;\n業務影響估算:&#39;)]
n24[impact = result[&#39;business_imp...]
n25[print(f&quot; 預估財務影響: ${impact[&...]
n26[print(f&quot; 潛在受影響使用者: {impact[&&#...]
n27[print(f&quot; 業務中斷風險: {impact[&#...]
n28[print(f&quot; 名譽風險: {impact[&#3...]
n29[print(&#39;\n優先級建議:&#39;)]
n30{for (i, recommendation) in enumerate(result&#...}
n31[print(f&#39; {i}. {recommenda...]
n32[]
n33[print(&#39;\n最高優先級漏洞:&#39;)]
n34{for (i, finding) in enumerate(result[...}
n35[print(f&quot; {i}. {finding.get&#...]
n36[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 -->|Yes| n31
n30 -->|No| n32
n31 --> n30
n32 --> n33
n33 --> n34
n34 -->|Yes| n35
n34 -->|No| n36
n35 --> n34
n36 --> n2
933. integration aiva integration examples enhanced risk assessment demo Function example trend analysis
flowchart TB
n1([開始])
n2([結束])
n3['風險趨勢分析範例']
n4[engine = EnhancedRiskAssessme...]
n5[previous_assessment = {'business_risk_sc...]
n6[current_findings = [{'vulnerability_...]
n7[context = {'environment': &a...]
n8[current_assessment = engine.assess_risk(c...]
n9[trend = engine.compare_risk_...]
n10[print('\n' + '=&a...]
n11[print('風險趨勢分析')]
n12[print('=' * 80)]
n13[print(f"上月業務風險分數: {trend[&#...]
n14[print(f"本月業務風險分數: {trend[&#...]
n15[print(f"變化: {trend['sco...]
n16[print(f"趨勢: {trend['tre...]
n17[print(f"改善百分比: {trend['...]
n18{if trend['trend'] == &...}
n19[print('\n✅ 風險下降,安全態勢正在改善!')]
n20{if trend['trend'] == &...}
n21[print('\n⚠️ 風險上升,需要加強安全措施!')]
n22[print('\n➡️ 風險穩定,繼續保持當前安全實踐'&...]
n23[]
n24[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n24
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n23
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;風險趨勢分析範例&#39;]
n4[engine = EnhancedRiskAssessme...]
n5[previous_assessment = {&#39;business_risk_sc...]
n6[current_findings = [{&#39;vulnerability_...]
n7[context = {&#39;environment&#39;: &a...]
n8[current_assessment = engine.assess_risk(c...]
n9[trend = engine.compare_risk_...]
n10[print(&#39;\n&#39; + &#39;=&a...]
n11[print(&#39;風險趨勢分析&#39;)]
n12[print(&#39;=&#39; * 80)]
n13[print(f&quot;上月業務風險分數: {trend[&#...]
n14[print(f&quot;本月業務風險分數: {trend[&#...]
n15[print(f&quot;變化: {trend[&#39;sco...]
n16[print(f&quot;趨勢: {trend[&#39;tre...]
n17[print(f&quot;改善百分比: {trend[&#39;...]
n18{if trend[&#39;trend&#39;] == &...}
n19[print(&#39;\n✅ 風險下降,安全態勢正在改善!&#39;)]
n20{if trend[&#39;trend&#39;] == &...}
n21[print(&#39;\n⚠️ 風險上升,需要加強安全措施!&#39;)]
n22[print(&#39;\n➡️ 風險穩定,繼續保持當前安全實踐&#39;&...]
n23[]
n24[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n24
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n23
n22 --> n23
n23 --> n24
n24 --> n2
934. integration aiva integration middlewares rate limiter Function init
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(app)]
n4[self.rps = rps]
n5[self.burst = burst]
n6[self.buckets: dict[str, TokenBucket] = defaultdic...]
n7[self.cleanup_interval = 300]
n8[self.last_cleanup = time.time()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(app)]
n4[self.rps = rps]
n5[self.burst = burst]
n6[self.buckets: dict[str, TokenBucket] = defaultdic...]
n7[self.cleanup_interval = 300]
n8[self.last_cleanup = time.time()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
935. integration aiva integration middlewares rate limiter Function get client ip
flowchart TB
n1([開始])
n2([結束])
n3['獲取客戶端 IP 地址']
n4[forwarded_for = request.headers.get(...]
n5{if forwarded_for}
n6[return forwarded_for.split(','...]
n7[]
n8[real_ip = request.headers.get(...]
n9{if real_ip}
n10[return real_ip]
n11[]
n12[return request.client.host if request...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取客戶端 IP 地址&#39;]
n4[forwarded_for = request.headers.get(...]
n5{if forwarded_for}
n6[return forwarded_for.split(&#39;,&#39...]
n7[]
n8[real_ip = request.headers.get(...]
n9{if real_ip}
n10[return real_ip]
n11[]
n12[return request.client.host if request...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n2
936. integration aiva integration observability metrics Function enter
flowchart TB
n1([開始])
n2([結束])
n3[self.start_time = time.perf_counter()]
n4[return self]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.start_time = time.perf_counter()]
n4[return self]
n1 --> n3
n3 --> n4
n4 --> n2
937. integration aiva integration observability metrics Function exit
flowchart TB
n1([開始])
n2([結束])
n3{if self.start_time is not None}
n4[self.duration = time.perf_counter() ...]
n5[]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if self.start_time is not None}
n4[self.duration = time.perf_counter() ...]
n5[]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n2
938. integration aiva integration observability metrics Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.start_time = None]
n4[self.duration = None]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.start_time = None]
n4[self.duration = None]
n1 --> n3
n3 --> n4
n4 --> n2
939. integration aiva integration observability metrics Function create timer
flowchart TB
n1([開始])
n2([結束])
n3['創建計時器上下文管理器']
n4[return MetricsTimer()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建計時器上下文管理器&#39;]
n4[return MetricsTimer()]
n1 --> n3
n3 --> n4
n4 --> n2
940. integration aiva integration observability metrics Function elapsed
flowchart TB
n1([開始])
n2([結束])
n3['獲取經過的時間(秒)']
n4{if self.duration is not None}
n5[return self.duration]
n6[]
n7{if self.start_time is not None}
n8[return time.perf_counter() - self.sta...]
n9[]
n10[return 0.0]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取經過的時間(秒)&#39;]
n4{if self.duration is not None}
n5[return self.duration]
n6[]
n7{if self.start_time is not None}
n8[return time.perf_counter() - self.sta...]
n9[]
n10[return 0.0]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
941. integration aiva integration observability metrics Function get metrics
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取 Prometheus 格式的指標\n\n Ret...]
n4{if not self.enabled}
n5[return ('# Prometheus metrics not ava...]
n6[]
n7[return (generate_latest(), CONTENT_TY...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取 Prometheus 格式的指標\n\n Ret...]
n4{if not self.enabled}
n5[return (&#39;# Prometheus metrics not ava...]
n6[]
n7[return (generate_latest(), CONTENT_TY...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
942. integration aiva integration observability metrics Function record finding processed
flowchart TB
n1([開始])
n2([結束])
n3['記錄處理的發現指標']
n4{if not self.enabled}
n5[return]
n6[]
n7[self.findings_processed_total.labels(status=status...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄處理的發現指標&#39;]
n4{if not self.enabled}
n5[return]
n6[]
n7[self.findings_processed_total.labels(status=status...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
943. integration aiva integration observability metrics Function record http request
flowchart TB
n1([開始])
n2([結束])
n3['記錄 HTTP 請求指標']
n4{if not self.enabled}
n5[return]
n6[]
n7[self.http_requests_total.labels(method=method, end...]
n8[self.http_request_duration.labels(method=method, e...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄 HTTP 請求指標&#39;]
n4{if not self.enabled}
n5[return]
n6[]
n7[self.http_requests_total.labels(method=method, end...]
n8[self.http_request_duration.labels(method=method, e...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
944. integration aiva integration observability metrics Function record report generated
flowchart TB
n1([開始])
n2([結束])
n3['記錄生成的報告指標']
n4{if not self.enabled}
n5[return]
n6[]
n7[self.reports_generated_total.labels(format=format_...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄生成的報告指標&#39;]
n4{if not self.enabled}
n5[return]
n6[]
n7[self.reports_generated_total.labels(format=format_...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
945. integration aiva integration observability metrics Function record vulnerability found
flowchart TB
n1([開始])
n2([結束])
n3['記錄發現的漏洞指標']
n4{if not self.enabled}
n5[return]
n6[]
n7[self.vulnerabilities_found.labels(severity=severit...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄發現的漏洞指標&#39;]
n4{if not self.enabled}
n5[return]
n6[]
n7[self.vulnerabilities_found.labels(severity=severit...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
946. integration aiva integration perf feedback improvement suggestion generator Function generate suggestions
flowchart TB
n1([開始])
n2([結束])
n3['生成改進建議']
n4[suggestions = []]
n5[performance_score = performance_data.get...]
n6{if performance_score < 50}
n7[suggestions.append('建議優化掃描配置以提升性能&...]
n8[]
n9[finding_count = len(findings)]
n10{if finding_count > 50}
n11[suggestions.append('發現大量漏洞,建議分階段修復&...]
n12{if finding_count == 0}
n13[suggestions.append('未發現漏洞,建議定期重複掃描&...]
n14[]
n15[]
n16[return suggestions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n15
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成改進建議&#39;]
n4[suggestions = []]
n5[performance_score = performance_data.get...]
n6{if performance_score &lt; 50}
n7[suggestions.append(&#39;建議優化掃描配置以提升性能&...]
n8[]
n9[finding_count = len(findings)]
n10{if finding_count &gt; 50}
n11[suggestions.append(&#39;發現大量漏洞,建議分階段修復&&#...]
n12{if finding_count == 0}
n13[suggestions.append(&#39;未發現漏洞,建議定期重複掃描&&#...]
n14[]
n15[]
n16[return suggestions]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n15
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
947. integration aiva integration reception data reception layer Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._db = db]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._db = db]
n1 --> n3
n3 --> n2
948. integration aiva integration reception experience models Function repr
flowchart TB
n1([開始])
n2([結束])
n3[return f"<ModelTrainingHistory(id=...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return f&quot;&lt;ModelTrainingHistory(id=...]
n1 --> n3
n3 --> n2
949. integration aiva integration reception experience repository Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化資料庫連接\n\n Args:\n datab...]
n4[self.engine = create_engine(databa...]
n5[self.SessionLocal = sessionmaker(bind=se...]
n6[Base.metadata.create_all(self.engine)]
n7[logger.info(f'ExperienceRepository initia...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化資料庫連接\n\n Args:\n datab...]
n4[self.engine = create_engine(databa...]
n5[self.SessionLocal = sessionmaker(bind=se...]
n6[Base.metadata.create_all(self.engine)]
n7[logger.info(f&#39;ExperienceRepository initia...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
950. integration aiva integration reception experience repository Function add samples to dataset
flowchart TB
n1([開始])
n2([結束])
n3['將經驗樣本加入資料集\n\n Args:\n dat...]
n4[session = self.get_session()]
n5[try]
n6[count = 0]
n7{for exp_id in experience_ids}
n8[sample = DatasetSample(datase...]
n9[session.add(sample)]
n10[count += 1]
n11[]
n12[session.commit()]
n13[logger.info(f'Added {count} sam...]
n14[return count]
n15[]
n16[except Exception]
n17[session.rollback()]
n18[logger.error(f'Failed to add samples to d...]
n19[raise]
n20[finally]
n21[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n16
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n20
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n15
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將經驗樣本加入資料集\n\n Args:\n dat...]
n4[session = self.get_session()]
n5[try]
n6[count = 0]
n7{for exp_id in experience_ids}
n8[sample = DatasetSample(datase...]
n9[session.add(sample)]
n10[count += 1]
n11[]
n12[session.commit()]
n13[logger.info(f&#39;Added {count} sam...]
n14[return count]
n15[]
n16[except Exception]
n17[session.rollback()]
n18[logger.error(f&#39;Failed to add samples to d...]
n19[raise]
n20[finally]
n21[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n16
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n20
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n15
n20 --> n21
n21 --> n2
951. integration aiva integration reception experience repository Function create training dataset
flowchart TB
n1([開始])
n2([結束])
n3['創建訓練資料集\n\n Args:\n name: ...]
n4[session = self.get_session()]
n5[try]
n6[dataset_id = f'dataset_{uuid4()....]
n7[dataset = TrainingDataset(data...]
n8[session.add(dataset)]
n9[session.commit()]
n10[session.refresh(dataset)]
n11[logger.info(f"Created training dataset &...]
n12[return dataset]
n13[]
n14[except Exception]
n15[session.rollback()]
n16[logger.error(f'Failed to create training ...]
n17[raise]
n18[finally]
n19[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n13
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建訓練資料集\n\n Args:\n name: ...]
n4[session = self.get_session()]
n5[try]
n6[dataset_id = f&#39;dataset_{uuid4()....]
n7[dataset = TrainingDataset(data...]
n8[session.add(dataset)]
n9[session.commit()]
n10[session.refresh(dataset)]
n11[logger.info(f&quot;Created training dataset &...]
n12[return dataset]
n13[]
n14[except Exception]
n15[session.rollback()]
n16[logger.error(f&#39;Failed to create training ...]
n17[raise]
n18[finally]
n19[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n13
n18 --> n19
n19 --> n2
952. integration aiva integration reception experience repository Function get dataset samples
flowchart TB
n1([開始])
n2([結束])
n3['獲取資料集的所有樣本\n\n Args:\n dat...]
n4[session = self.get_session()]
n5[try]
n6[results = session.query(Datase...]
n7[return results]
n8[]
n9[finally]
n10[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取資料集的所有樣本\n\n Args:\n dat...]
n4[session = self.get_session()]
n5[try]
n6[results = session.query(Datase...]
n7[return results]
n8[]
n9[finally]
n10[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
953. integration aiva integration reception experience repository Function get experience
flowchart TB
n1([開始])
n2([結束])
n3['獲取單一經驗記錄\n\n Args:\n exper...]
n4[session = self.get_session()]
n5[try]
n6[return session.query(ExperienceRecord...]
n7[]
n8[finally]
n9[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取單一經驗記錄\n\n Args:\n exper...]
n4[session = self.get_session()]
n5[try]
n6[return session.query(ExperienceRecord...]
n7[]
n8[finally]
n9[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
954. integration aiva integration reception experience repository Function get session
flowchart TB
n1([開始])
n2([結束])
n3['獲取資料庫會話']
n4[return self.SessionLocal()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取資料庫會話&#39;]
n4[return self.SessionLocal()]
n1 --> n3
n3 --> n4
n4 --> n2
955. integration aiva integration reception experience repository Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['獲取經驗庫統計資訊\n\n Returns:\n 統...]
n4[session = self.get_session()]
n5[try]
n6[total_experiences = session.query(func.c...]
n7[avg_score = session.query(func.a...]
n8[attack_type_counts = session.query(Experi...]
n9[return {'total_experiences':...]
n10[]
n11[finally]
n12[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取經驗庫統計資訊\n\n Returns:\n 統...]
n4[session = self.get_session()]
n5[try]
n6[total_experiences = session.query(func.c...]
n7[avg_score = session.query(func.a...]
n8[attack_type_counts = session.query(Experi...]
n9[return {&#39;total_experiences&#39;:...]
n10[]
n11[finally]
n12[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
956. integration aiva integration reception experience repository Function get top experiences
flowchart TB
n1([開始])
n2([結束])
n3['獲取評分最高的經驗記錄\n\n Args:\n at...]
n4[return self.query_experiences(attack_...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取評分最高的經驗記錄\n\n Args:\n at...]
n4[return self.query_experiences(attack_...]
n1 --> n3
n3 --> n4
n4 --> n2
957. integration aiva integration reception experience repository Function query experiences
flowchart TB
n1([開始])
n2([結束])
n3['查詢經驗記錄\n\n Args:\n attack_...]
n4[session = self.get_session()]
n5[try]
n6[query = session.query(Experi...]
n7{if attack_type}
n8[query = query.filter(Experie...]
n9[]
n10{if min_score is not None}
n11[query = query.filter(Experie...]
n12[]
n13{if max_score is not None}
n14[query = query.filter(Experie...]
n15[]
n16[query = query.order_by(desc(...]
n17[return query.limit(limit).offset(offs...]
n18[]
n19[finally]
n20[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;查詢經驗記錄\n\n Args:\n attack_...]
n4[session = self.get_session()]
n5[try]
n6[query = session.query(Experi...]
n7{if attack_type}
n8[query = query.filter(Experie...]
n9[]
n10{if min_score is not None}
n11[query = query.filter(Experie...]
n12[]
n13{if max_score is not None}
n14[query = query.filter(Experie...]
n15[]
n16[query = query.order_by(desc(...]
n17[return query.limit(limit).offset(offs...]
n18[]
n19[finally]
n20[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
958. integration aiva integration reception experience repository Function save experience
flowchart TB
n1([開始])
n2([結束])
n3['保存經驗記錄\n\n Args:\n plan_id...]
n4[session = self.get_session()]
n5[try]
n6[experience_id = f'exp_{uuid4().h...]
n7[record = ExperienceRecord(exp...]
n8[session.add(record)]
n9[session.commit()]
n10[session.refresh(record)]
n11[logger.info(f'Saved experience {expe...]
n12[return record]
n13[]
n14[except Exception]
n15[session.rollback()]
n16[logger.error(f'Failed to save experience:...]
n17[raise]
n18[finally]
n19[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n13
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存經驗記錄\n\n Args:\n plan_id...]
n4[session = self.get_session()]
n5[try]
n6[experience_id = f&#39;exp_{uuid4().h...]
n7[record = ExperienceRecord(exp...]
n8[session.add(record)]
n9[session.commit()]
n10[session.refresh(record)]
n11[logger.info(f&#39;Saved experience {expe...]
n12[return record]
n13[]
n14[except Exception]
n15[session.rollback()]
n16[logger.error(f&#39;Failed to save experience:...]
n17[raise]
n18[finally]
n19[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n13
n18 --> n19
n19 --> n2
959. integration aiva integration reception experience repository Function save training history
flowchart TB
n1([開始])
n2([結束])
n3['保存訓練歷史\n\n Args:\n model_n...]
n4[session = self.get_session()]
n5[try]
n6[training_id = f'train_{uuid4().h...]
n7[history = ModelTrainingHistory...]
n8[session.add(history)]
n9[session.commit()]
n10[session.refresh(history)]
n11[logger.info(f'Created training history ...]
n12[return history]
n13[]
n14[except Exception]
n15[session.rollback()]
n16[logger.error(f'Failed to save training hi...]
n17[raise]
n18[finally]
n19[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n13
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存訓練歷史\n\n Args:\n model_n...]
n4[session = self.get_session()]
n5[try]
n6[training_id = f&#39;train_{uuid4().h...]
n7[history = ModelTrainingHistory...]
n8[session.add(history)]
n9[session.commit()]
n10[session.refresh(history)]
n11[logger.info(f&#39;Created training history &#...]
n12[return history]
n13[]
n14[except Exception]
n15[session.rollback()]
n16[logger.error(f&#39;Failed to save training hi...]
n17[raise]
n18[finally]
n19[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n14
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n18
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n13
n18 --> n19
n19 --> n2
960. integration aiva integration reception experience repository Function update training history
flowchart TB
n1([開始])
n2([結束])
n3['更新訓練歷史\n\n Args:\n trainin...]
n4[session = self.get_session()]
n5[try]
n6[history = session.query(ModelT...]
n7{if not history}
n8[logger.warning(f'Training history {t...]
n9[return]
n10[]
n11{if status}
n12[history.status = status]
n13[]
n14{if final_loss is not None}
n15[history.final_loss = final_loss]
n16[]
n17{if final_accuracy is not None}
n18[history.final_accuracy = final_accuracy]
n19[]
n20{if training_metrics}
n21[history.training_metrics = training_metrics]
n22[]
n23{if model_path}
n24[history.model_path = model_path]
n25[]
n26{if status in ('completed', &a...}
n27[history.completed_at = datetime.now()]
n28[]
n29[session.commit()]
n30[logger.info(f'Updated training history ...]
n31[]
n32[except Exception]
n33[session.rollback()]
n34[logger.error(f'Failed to update training ...]
n35[raise]
n36[finally]
n37[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n32
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n36
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n31
n36 --> n37
n37 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新訓練歷史\n\n Args:\n trainin...]
n4[session = self.get_session()]
n5[try]
n6[history = session.query(ModelT...]
n7{if not history}
n8[logger.warning(f&#39;Training history {t...]
n9[return]
n10[]
n11{if status}
n12[history.status = status]
n13[]
n14{if final_loss is not None}
n15[history.final_loss = final_loss]
n16[]
n17{if final_accuracy is not None}
n18[history.final_accuracy = final_accuracy]
n19[]
n20{if training_metrics}
n21[history.training_metrics = training_metrics]
n22[]
n23{if model_path}
n24[history.model_path = model_path]
n25[]
n26{if status in (&#39;completed&#39;, &a...}
n27[history.completed_at = datetime.now()]
n28[]
n29[session.commit()]
n30[logger.info(f&#39;Updated training history &#...]
n31[]
n32[except Exception]
n33[session.rollback()]
n34[logger.error(f&#39;Failed to update training ...]
n35[raise]
n36[finally]
n37[session.close()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n32
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n36
n32 --> n33
n33 --> n34
n34 --> n35
n35 --> n31
n36 --> n37
n37 --> n2
961. integration aiva integration reception lifecycle manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.session = session]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.session = session]
n1 --> n3
n3 --> n2
962. integration aiva integration reception lifecycle manager Function assess exploitability
flowchart TB
n1([開始])
n2([結束])
n3['評估可利用性']
n4[confidence = finding.vulnerabilit...]
n5{if confidence == 'HIGH'}
n6[return 'high']
n7{if confidence == 'MEDIUM'}
n8[return 'medium']
n9[return 'low']
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n11
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;評估可利用性&#39;]
n4[confidence = finding.vulnerabilit...]
n5{if confidence == &#39;HIGH&#39;}
n6[return &#39;high&#39;]
n7{if confidence == &#39;MEDIUM&#39;}
n8[return &#39;medium&#39;]
n9[return &#39;low&#39;]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n11
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n10
n9 --> n10
n10 --> n11
n11 --> n2
963. integration aiva integration reception lifecycle manager Function calculate initial risk score
flowchart TB
n1([開始])
n2([結束])
n3['計算初始風險分數']
n4[severity_scores = {'CRITICAL'...]
n5[base_score = severity_scores.get(...]
n6[confidence_multipliers = {'HIGH&#...]
n7[confidence_multiplier = confidence_multiplie...]
n8[asset = self.session.query(A...]
n9{if asset}
n10[business_multipliers = {BusinessCriticality...]
n11[business_multiplier = business_multipliers...]
n12[business_multiplier = 1.0]
n13[]
n14[return round(base_score * confidence_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算初始風險分數&#39;]
n4[severity_scores = {&#39;CRITICAL&#39...]
n5[base_score = severity_scores.get(...]
n6[confidence_multipliers = {&#39;HIGH&#...]
n7[confidence_multiplier = confidence_multiplie...]
n8[asset = self.session.query(A...]
n9{if asset}
n10[business_multipliers = {BusinessCriticality...]
n11[business_multiplier = business_multipliers...]
n12[business_multiplier = 1.0]
n13[]
n14[return round(base_score * confidence_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n2
964. integration aiva integration reception lifecycle manager Function extract location key
flowchart TB
n1([開始])
n2([結束])
n3['生成位置唯一鍵(用於去重)']
n4[url = str(finding.target.u...]
n5[param = finding.target.param...]
n6[method = finding.target.metho...]
n7[return f'{url}:{param}:...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成位置唯一鍵(用於去重)&#39;]
n4[url = str(finding.target.u...]
n5[param = finding.target.param...]
n6[method = finding.target.metho...]
n7[return f&#39;{url}:{param}:&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
965. integration aiva integration reception lifecycle manager Function extract location
flowchart TB
n1([開始])
n2([結束])
n3['提取漏洞位置資訊']
n4[return {'url': str(findi...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取漏洞位置資訊&#39;]
n4[return {&#39;url&#39;: str(findi...]
n1 --> n3
n3 --> n4
n4 --> n2
966. integration aiva integration reception lifecycle manager Function extract vuln type
flowchart TB
n1([開始])
n2([結束])
n3['提取漏洞類型']
n4[return finding.vulnerability.name.val...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取漏洞類型&#39;]
n4[return finding.vulnerability.name.val...]
n1 --> n3
n3 --> n4
n4 --> n2
967. integration aiva integration reception lifecycle manager Function generate asset id
flowchart TB
n1([開始])
n2([結束])
n3['生成資產唯一 ID']
n4[content = f'{asset_type}:{asse...]
n5[return f'asset_{hashlib.sha256(conte...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成資產唯一 ID&#39;]
n4[content = f&#39;{asset_type}:{asse...]
n5[return f&#39;asset_{hashlib.sha256(conte...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
968. integration aiva integration reception lifecycle manager Function generate vulnerability id
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成漏洞唯一 ID(用於去重)\n\n 基於:資產 I...]
n4[vuln_type = self._extract_vuln_t...]
n5[location = self._extract_locati...]
n6[content = f'{asset_id}:{vuln_t...]
n7[return f'vuln_{hashlib.sha256(conten...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成漏洞唯一 ID(用於去重)\n\n 基於:資產 I...]
n4[vuln_type = self._extract_vuln_t...]
n5[location = self._extract_locati...]
n6[content = f&#39;{asset_id}:{vuln_t...]
n7[return f&#39;vuln_{hashlib.sha256(conten...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
969. integration aiva integration reception lifecycle manager Function infer asset id from finding
flowchart TB
n1([開始])
n2([結束])
n3['從 Finding 推斷資產 ID']
n4[target_url = str(finding.target.u...]
n5[return self._generate_asset_id('url&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從 Finding 推斷資產 ID&#39;]
n4[target_url = str(finding.target.u...]
n5[return self._generate_asset_id(&#39;url&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
970. integration aiva integration reception lifecycle manager Function log status change
flowchart TB
n1([開始])
n2([結束])
n3['記錄狀態變更歷史']
n4[history = VulnerabilityHistory...]
n5[self.session.add(history)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄狀態變更歷史&#39;]
n4[history = VulnerabilityHistory...]
n5[self.session.add(history)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
971. integration aiva integration reception lifecycle manager Function add vulnerability tag
flowchart TB
n1([開始])
n2([結束])
n3['\n 為漏洞添加標籤\n\n Args:\n ...]
n4[existing = self.session.query(V...]
n5{if existing}
n6[logger.debug(f'Tag already exists: {...]
n7[return existing]
n8[]
n9[tag_obj = VulnerabilityTag(vul...]
n10[self.session.add(tag_obj)]
n11[self.session.commit()]
n12[logger.info(f'Added tag to vulnerability:...]
n13[return tag_obj]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 為漏洞添加標籤\n\n Args:\n ...]
n4[existing = self.session.query(V...]
n5{if existing}
n6[logger.debug(f&#39;Tag already exists: {...]
n7[return existing]
n8[]
n9[tag_obj = VulnerabilityTag(vul...]
n10[self.session.add(tag_obj)]
n11[self.session.commit()]
n12[logger.info(f&#39;Added tag to vulnerability:...]
n13[return tag_obj]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
972. integration aiva integration reception lifecycle manager Function assign vulnerability
flowchart TB
n1([開始])
n2([結束])
n3['\n 指派漏洞給特定人員\n\n Args:\n ...]
n4[vulnerability = self.session.query(V...]
n5{if not vulnerability}
n6[return None]
n7[]
n8[old_assigned = vulnerability.assign...]
n9[vulnerability.assigned_to = assigned_to]
n10[history = VulnerabilityHistory...]
n11[self.session.add(history)]
n12[self.session.commit()]
n13[logger.info(f'Assigned vulnerability ...]
n14[return vulnerability]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 指派漏洞給特定人員\n\n Args:\n ...]
n4[vulnerability = self.session.query(V...]
n5{if not vulnerability}
n6[return None]
n7[]
n8[old_assigned = vulnerability.assign...]
n9[vulnerability.assigned_to = assigned_to]
n10[history = VulnerabilityHistory...]
n11[self.session.add(history)]
n12[self.session.commit()]
n13[logger.info(f&#39;Assigned vulnerability ...]
n14[return vulnerability]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
973. integration aiva integration reception lifecycle manager Function calculate mttr
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算平均修復時間 (Mean Time To Resolve...]
n4[cutoff_date = datetime.utcnow() - ...]
n5[query = self.session.query(V...]
n6{if severity}
n7[query = query.filter(Vulnera...]
n8[]
n9[vulnerabilities = query.all()]
n10{if not vulnerabilities}
n11[return {'count': 0, &...]
n12[]
n13[resolution_times = []]
n14{for vuln in vulnerabilities}
n15{if vuln.fixed_at and vuln.firs...}
n16[delta = vuln.fixed_at - vuln...]
n17[hours = delta.total_seconds(...]
n18[resolution_times.append(hours)]
n19[]
n20[]
n21[return {'count': len(res...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 -->|Yes| n16
n15 -->|No| n19
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n14
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算平均修復時間 (Mean Time To Resolve...]
n4[cutoff_date = datetime.utcnow() - ...]
n5[query = self.session.query(V...]
n6{if severity}
n7[query = query.filter(Vulnera...]
n8[]
n9[vulnerabilities = query.all()]
n10{if not vulnerabilities}
n11[return {&#39;count&#39;: 0, &...]
n12[]
n13[resolution_times = []]
n14{for vuln in vulnerabilities}
n15{if vuln.fixed_at and vuln.firs...}
n16[delta = vuln.fixed_at - vuln...]
n17[hours = delta.total_seconds(...]
n18[resolution_times.append(hours)]
n19[]
n20[]
n21[return {&#39;count&#39;: len(res...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 -->|Yes| n16
n15 -->|No| n19
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n14
n20 --> n21
n21 --> n2
974. integration aiva integration reception lifecycle manager Function get asset vulnerabilities
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取資產的所有漏洞\n\n Args:\n ...]
n4[query = self.session.query(V...]
n5{if not include_fixed}
n6[query = query.filter(Vulnera...]
n7[]
n8[return query.order_by(Vulnerability.r...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取資產的所有漏洞\n\n Args:\n ...]
n4[query = self.session.query(V...]
n5{if not include_fixed}
n6[query = query.filter(Vulnera...]
n7[]
n8[return query.order_by(Vulnerability.r...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
975. integration aiva integration reception lifecycle manager Function get overdue vulnerabilities
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取所有逾期的漏洞\n\n Returns:\n ...]
n4[return self.session.query(Vulnerabili...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取所有逾期的漏洞\n\n Returns:\n ...]
n4[return self.session.query(Vulnerabili...]
n1 --> n3
n3 --> n4
n4 --> n2
976. integration aiva integration reception lifecycle manager Function process finding
flowchart TB
n1([開始])
n2([結束])
n3['\n 處理 Finding,進行漏洞去重和生命週期管理\n\n ...]
n4{if not asset_id}
n5[asset_id = self._infer_asset_id...]
n6[]
n7[vulnerability_id = self._generate_vulne...]
n8[vulnerability = self.session.query(V...]
n9[is_new = False]
n10{if vulnerability}
n11[vulnerability.last_detected_at = datetime.utcnow()]
n12{if vulnerability.status == Vul...}
n13[old_status = vulnerability.status]
n14[vulnerability.status = VulnerabilityStatus....]
n15[vulnerability.fixed_at = None]
n16[vulnerability.verified_fixed_at = None]
n17[self._log_status_change(vulnerability_id, old_stat...]
n18[logger.warning(f'Previously fixed vulnera...]
n19[]
n20[logger.info(f'Updated existing vulnerabil...]
n21[is_new = True]
n22[vulnerability = Vulnerability(vulner...]
n23[self.session.add(vulnerability)]
n24[logger.info(f'Created new vulnerability: ...]
n25[]
n26[self.session.commit()]
n27[return (vulnerability, is_new)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n21
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n19
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n25
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 處理 Finding,進行漏洞去重和生命週期管理\n\n ...]
n4{if not asset_id}
n5[asset_id = self._infer_asset_id...]
n6[]
n7[vulnerability_id = self._generate_vulne...]
n8[vulnerability = self.session.query(V...]
n9[is_new = False]
n10{if vulnerability}
n11[vulnerability.last_detected_at = datetime.utcnow()]
n12{if vulnerability.status == Vul...}
n13[old_status = vulnerability.status]
n14[vulnerability.status = VulnerabilityStatus....]
n15[vulnerability.fixed_at = None]
n16[vulnerability.verified_fixed_at = None]
n17[self._log_status_change(vulnerability_id, old_stat...]
n18[logger.warning(f&#39;Previously fixed vulnera...]
n19[]
n20[logger.info(f&#39;Updated existing vulnerabil...]
n21[is_new = True]
n22[vulnerability = Vulnerability(vulner...]
n23[self.session.add(vulnerability)]
n24[logger.info(f&#39;Created new vulnerability: ...]
n25[]
n26[self.session.commit()]
n27[return (vulnerability, is_new)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n21
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n19
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n25
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n2
977. integration aiva integration reception lifecycle manager Function register asset
flowchart TB
n1([開始])
n2([結束])
n3['\n 註冊或更新資產\n\n Args:\n ...]
n4[asset_id = self._generate_asset...]
n5[asset = self.session.query(A...]
n6{if asset}
n7[asset.last_scanned_at = datetime.utcnow()]
n8{if name}
n9[asset.name = name]
n10[]
n11{if owner}
n12[asset.owner = owner]
n13[]
n14{if tags}
n15[asset.tags = tags]
n16[]
n17{if technology_stack}
n18[asset.technology_stack = technology_stack]
n19[]
n20[logger.info(f'Updated existing asset: ...]
n21[asset = Asset(asset_id=asset...]
n22[self.session.add(asset)]
n23[logger.info(f'Registered new asset: {...]
n24[]
n25[self.session.commit()]
n26[return asset]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n21
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n24
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 註冊或更新資產\n\n Args:\n ...]
n4[asset_id = self._generate_asset...]
n5[asset = self.session.query(A...]
n6{if asset}
n7[asset.last_scanned_at = datetime.utcnow()]
n8{if name}
n9[asset.name = name]
n10[]
n11{if owner}
n12[asset.owner = owner]
n13[]
n14{if tags}
n15[asset.tags = tags]
n16[]
n17{if technology_stack}
n18[asset.technology_stack = technology_stack]
n19[]
n20[logger.info(f&#39;Updated existing asset: ...]
n21[asset = Asset(asset_id=asset...]
n22[self.session.add(asset)]
n23[logger.info(f&#39;Registered new asset: {...]
n24[]
n25[self.session.commit()]
n26[return asset]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n21
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n24
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
978. integration aiva integration reception lifecycle manager Function update vulnerability status
flowchart TB
n1([開始])
n2([結束])
n3['\n 更新漏洞狀態\n\n Args:\n ...]
n4[vulnerability = self.session.query(V...]
n5{if not vulnerability}
n6[logger.warning(f'Vulnerability not found:...]
n7[return None]
n8[]
n9[old_status = vulnerability.status]
n10{if old_status == new_status}
n11[logger.debug(f'Status unchanged for vulne...]
n12[return vulnerability]
n13[]
n14[vulnerability.status = new_status]
n15{if new_status == Vulnerability...}
n16[vulnerability.fixed_at = datetime.utcnow()]
n17[]
n18[self._log_status_change(vulnerability_id, old_stat...]
n19[self.session.commit()]
n20[logger.info(f'Updated vulnerability statu...]
n21[return vulnerability]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 更新漏洞狀態\n\n Args:\n ...]
n4[vulnerability = self.session.query(V...]
n5{if not vulnerability}
n6[logger.warning(f&#39;Vulnerability not found:...]
n7[return None]
n8[]
n9[old_status = vulnerability.status]
n10{if old_status == new_status}
n11[logger.debug(f&#39;Status unchanged for vulne...]
n12[return vulnerability]
n13[]
n14[vulnerability.status = new_status]
n15{if new_status == Vulnerability...}
n16[vulnerability.fixed_at = datetime.utcnow()]
n17[]
n18[self._log_status_change(vulnerability_id, old_stat...]
n19[self.session.commit()]
n20[logger.info(f&#39;Updated vulnerability statu...]
n21[return vulnerability]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
979. integration aiva integration reception models enhanced Function repr
flowchart TB
n1([開始])
n2([結束])
n3[return f'<FindingRecord(finding_id...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return f&#39;&lt;FindingRecord(finding_id...]
n1 --> n3
n3 --> n2
980. integration aiva integration reception models enhanced Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典']
n4[return {'vulnerability_id': ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典&#39;]
n4[return {&#39;vulnerability_id&#39;: ...]
n1 --> n3
n3 --> n4
n4 --> n2
981. integration aiva integration reception sql result database Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.database_url = database_url]
n4[self.auto_migrate = auto_migrate]
n5[engine_args: dict[str, Any] = {'...]
n6{if not database_url.startswith...}
n7[engine_args.update({'pool_size&&...]
n8[]
n9[self.engine = create_engine(databa...]
n10[self.SessionLocal = sessionmaker(autocom...]
n11{if auto_migrate}
n12[self._create_tables()]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.database_url = database_url]
n4[self.auto_migrate = auto_migrate]
n5[engine_args: dict[str, Any] = {&#39;...]
n6{if not database_url.startswith...}
n7[engine_args.update({&#39;pool_size&&...]
n8[]
n9[self.engine = create_engine(databa...]
n10[self.SessionLocal = sessionmaker(autocom...]
n11{if auto_migrate}
n12[self._create_tables()]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n2
982. integration aiva integration reception sql result database Function create tables
flowchart TB
n1([開始])
n2([結束])
n3['創建資料庫表']
n4[Base.metadata.create_all(bind=self.engine)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建資料庫表&#39;]
n4[Base.metadata.create_all(bind=self.engine)]
n1 --> n3
n3 --> n4
n4 --> n2
983. integration aiva integration reception sql result database Function get session
flowchart TB
n1([開始])
n2([結束])
n3['獲取資料庫 session']
n4[return self.SessionLocal()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取資料庫 session&#39;]
n4[return self.SessionLocal()]
n1 --> n3
n3 --> n4
n4 --> n2
984. integration aiva integration reception sql result database Function to finding payload
flowchart TB
n1([開始])
n2([結束])
n3['轉換為 FindingPayload 對象']
n4[raw_data_str: str = str(self.raw_data)]
n5[return FindingPayload.model_validate_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為 FindingPayload 對象&#39;]
n4[raw_data_str: str = str(self.raw_data)]
n5[return FindingPayload.model_validate_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
985. integration aiva integration remediation code fixer Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化代碼修復器\n\n Args:\n ...]
n4[self.api_key = api_key]
n5[self.model = model]
n6[self.use_litellm = use_litellm and LITE...]
n7[self.max_tokens = max_tokens]
n8[self.fix_history: list[dict[str, Any]] = ...]
n9{if self.use_litellm}
n10{if not LITELLM_AVAILABLE}
n11[logger.warning('litellm_not_available&...]
n12[self.use_litellm = False]
n13[litellm.api_key = api_key]
n14[logger.info('code_fixer_initialized&&...]
n15[]
n16{if OPENAI_AVAILABLE and api_key}
n17[openai.api_key = api_key]
n18[logger.info('code_fixer_initialized&&...]
n19[logger.warning('no_ai_api_available&&...]
n20[]
n21[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n21
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n20
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化代碼修復器\n\n Args:\n ...]
n4[self.api_key = api_key]
n5[self.model = model]
n6[self.use_litellm = use_litellm and LITE...]
n7[self.max_tokens = max_tokens]
n8[self.fix_history: list[dict[str, Any]] = ...]
n9{if self.use_litellm}
n10{if not LITELLM_AVAILABLE}
n11[logger.warning(&#39;litellm_not_available&...]
n12[self.use_litellm = False]
n13[litellm.api_key = api_key]
n14[logger.info(&#39;code_fixer_initialized&&...]
n15[]
n16{if OPENAI_AVAILABLE and api_key}
n17[openai.api_key = api_key]
n18[logger.info(&#39;code_fixer_initialized&&...]
n19[logger.warning(&#39;no_ai_api_available&&...]
n20[]
n21[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n21
n16 -->|Yes| n17
n16 -->|No| n19
n17 --> n18
n18 --> n20
n19 --> n20
n20 --> n21
n21 --> n2
986. integration aiva integration remediation code fixer Function build fix prompt
flowchart TB
n1([開始])
n2([結束])
n3['構建修復提示']
n4[prompt = f'Fix the following ...]
n5{if context}
n6[prompt += f'\nContext: {context}&am...]
n7[]
n8[prompt += '\n\nProvide:\n1. Fixed code\n2. Ex...]
n9[return prompt]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建修復提示&#39;]
n4[prompt = f&#39;Fix the following ...]
n5{if context}
n6[prompt += f&#39;\nContext: {context}&am...]
n7[]
n8[prompt += &#39;\n\nProvide:\n1. Fixed code\n2. Ex...]
n9[return prompt]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
987. integration aiva integration remediation code fixer Function fix with llm
flowchart TB
n1([開始])
n2([結束])
n3['使用 LLM 修復代碼']
n4[prompt = self._build_fix_prom...]
n5{if self.use_litellm}
n6[response = litellm.completion(m...]
n7[content = response.choices[0]....]
n8[response = openai.ChatCompletio...]
n9[content = response.choices[0]....]
n10[]
n11[return self._parse_llm_response(conte...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n10
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;使用 LLM 修復代碼&#39;]
n4[prompt = self._build_fix_prom...]
n5{if self.use_litellm}
n6[response = litellm.completion(m...]
n7[content = response.choices[0]....]
n8[response = openai.ChatCompletio...]
n9[content = response.choices[0]....]
n10[]
n11[return self._parse_llm_response(conte...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n10
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
988. integration aiva integration remediation code fixer Function fix with mock
flowchart TB
n1([開始])
n2([結束])
n3['Mock 模式修復']
n4[logger.debug('using_mock_fixer...]
n5{if vulnerability_type.lower() ...}
n6[fixed_code = self._mock_fix_sql_i...]
n7[explanation = 'Replaced string con...]
n8[confidence = 0.85]
n9{if vulnerability_type.lower() ...}
n10[fixed_code = self._mock_fix_xss(c...]
n11[explanation = 'Added HTML escaping...]
n12[confidence = 0.8]
n13{if vulnerability_type.lower() ...}
n14[fixed_code = self._mock_fix_path_...]
n15[explanation = 'Added path validati...]
n16[confidence = 0.75]
n17[fixed_code = f'# TODO: Fix {vulne...]
n18[explanation = f'Generic fix templa...]
n19[confidence = 0.5]
n20[]
n21[]
n22[]
n23[return {'fixed_code': fixed_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n22
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n21
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n20
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Mock 模式修復&#39;]
n4[logger.debug(&#39;using_mock_fixer&#3...]
n5{if vulnerability_type.lower() ...}
n6[fixed_code = self._mock_fix_sql_i...]
n7[explanation = &#39;Replaced string con...]
n8[confidence = 0.85]
n9{if vulnerability_type.lower() ...}
n10[fixed_code = self._mock_fix_xss(c...]
n11[explanation = &#39;Added HTML escaping...]
n12[confidence = 0.8]
n13{if vulnerability_type.lower() ...}
n14[fixed_code = self._mock_fix_path_...]
n15[explanation = &#39;Added path validati...]
n16[confidence = 0.75]
n17[fixed_code = f&#39;# TODO: Fix {vulne...]
n18[explanation = f&#39;Generic fix templa...]
n19[confidence = 0.5]
n20[]
n21[]
n22[]
n23[return {&#39;fixed_code&#39;: fixed_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n22
n9 -->|Yes| n10
n9 -->|No| n13
n10 --> n11
n11 --> n12
n12 --> n21
n13 -->|Yes| n14
n13 -->|No| n17
n14 --> n15
n15 --> n16
n16 --> n20
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
989. integration aiva integration remediation code fixer Function mock fix path traversal
flowchart TB
n1([開始])
n2([結束])
n3['Mock 路徑遍歷修復']
n4{if language == 'python'}
n5[return f'import os\nfrom pathlib impo...]
n6[]
n7[return f'# Fixed Path Traversal - Add...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Mock 路徑遍歷修復&#39;]
n4{if language == &#39;python&#39;}
n5[return f&#39;import os\nfrom pathlib impo...]
n6[]
n7[return f&#39;# Fixed Path Traversal - Add...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
990. integration aiva integration remediation code fixer Function mock fix sql injection
flowchart TB
n1([開始])
n2([結束])
n3['Mock SQL 注入修復']
n4{if language == 'python' and &...}
n5[return code.replace('execute(&...]
n6[]
n7[return f'# Fixed SQL Injection\n{cod...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Mock SQL 注入修復&#39;]
n4{if language == &#39;python&#39; and &...}
n5[return code.replace(&#39;execute(&...]
n6[]
n7[return f&#39;# Fixed SQL Injection\n{cod...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
991. integration aiva integration remediation code fixer Function mock fix xss
flowchart TB
n1([開始])
n2([結束])
n3['Mock XSS 修復']
n4{if language == 'python' and (...}
n5[return f"import html\n# Fixed: Escape...]
n6[]
n7[return f'# Fixed XSS - Add HTML escap...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;Mock XSS 修復&#39;]
n4{if language == &#39;python&#39; and (...}
n5[return f&quot;import html\n# Fixed: Escape...]
n6[]
n7[return f&#39;# Fixed XSS - Add HTML escap...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
992. integration aiva integration remediation code fixer Function parse llm response
flowchart TB
n1([開始])
n2([結束])
n3['解析 LLM 響應']
n4[lines = content.split('\n')]
n5[fixed_code = '']
n6[explanation = '']
n7[confidence = 0.5]
n8[in_code = False]
n9[in_explanation = False]
n10{for line in lines}
n11{if 'FIXED_CODE:' in line or &...}
n12[in_code = not in_code]
n13[continue]
n14[]
n15{if 'EXPLANATION:' in line}
n16[in_explanation = True]
n17[continue]
n18[]
n19{if 'CONFIDENCE:' in line}
n20[in_explanation = False]
n21[with contextli...]
n22[confidence = float(line.split(':&...]
n23[continue]
n24[]
n25{if in_code}
n26[fixed_code += line + '\n']
n27{if in_explanation}
n28[explanation += line + ' ']
n29[]
n30[]
n31[]
n32[return {'fixed_code': fixed_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n31
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n10
n31 --> n32
n32 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;解析 LLM 響應&#39;]
n4[lines = content.split(&#39;\n&#39;)]
n5[fixed_code = &#39;&#39;]
n6[explanation = &#39;&#39;]
n7[confidence = 0.5]
n8[in_code = False]
n9[in_explanation = False]
n10{for line in lines}
n11{if &#39;FIXED_CODE:&#39; in line or &...}
n12[in_code = not in_code]
n13[continue]
n14[]
n15{if &#39;EXPLANATION:&#39; in line}
n16[in_explanation = True]
n17[continue]
n18[]
n19{if &#39;CONFIDENCE:&#39; in line}
n20[in_explanation = False]
n21[with contextli...]
n22[confidence = float(line.split(&#39;:&...]
n23[continue]
n24[]
n25{if in_code}
n26[fixed_code += line + &#39;\n&#39;]
n27{if in_explanation}
n28[explanation += line + &#39; &#39;]
n29[]
n30[]
n31[]
n32[return {&#39;fixed_code&#39;: fixed_...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n31
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n18
n16 --> n17
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n24
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n10
n31 --> n32
n32 --> n2
993. integration aiva integration remediation code fixer Function fix multiple issues
flowchart TB
n1([開始])
n2([結束])
n3['\n 批量修復多個問題\n\n Args:\n ...]
n4[logger.info('fixing_multiple_issues&&...]
n5[results = {'timestamp': date...]
n6{for issue in issues}
n7[fix = self.fix_vulnerabili...]
n8[results['fixes'].append...]
n9{if fix['status'] == &...}
n10[results['success_count'] ...]
n11[results['failed_count'] += 1]
n12[]
n13[]
n14[logger.info('multiple_issues_fixed&...]
n15[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 批量修復多個問題\n\n Args:\n ...]
n4[logger.info(&#39;fixing_multiple_issues&&...]
n5[results = {&#39;timestamp&#39;: date...]
n6{for issue in issues}
n7[fix = self.fix_vulnerabili...]
n8[results[&#39;fixes&#39;].append&#...]
n9{if fix[&#39;status&#39;] == &...}
n10[results[&#39;success_count&#39;] ...]
n11[results[&#39;failed_count&#39;] += 1]
n12[]
n13[]
n14[logger.info(&#39;multiple_issues_fixed&&#...]
n15[return results]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n13
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n6
n13 --> n14
n14 --> n15
n15 --> n2
994. integration aiva integration remediation code fixer Function fix vulnerability
flowchart TB
n1([開始])
n2([結束])
n3['\n 修復代碼漏洞\n\n Args:\n ...]
n4[logger.info('fixing_vulnerability&...]
n5[fix_id = hashlib.sha256(f'{co...]
n6[result = {'fix_id': fix_id, ...]
n7[try]
n8{if self.use_litellm or (OPENAI...}
n9[fixed = self._fix_with_llm(c...]
n10[result.update(fixed)]
n11[fixed = self._fix_with_mock(...]
n12[result.update(fixed)]
n13[]
n14[result['status'] = &&...]
n15[logger.info('vulnerability_fixed&#...]
n16[]
n17[except Exception]
n18[logger.error('fix_failed', fi...]
n19[result['status'] = &&...]
n20[result['error'] = str(...]
n21[self.fix_history.append(result)]
n22[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n17
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n21
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n16
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 修復代碼漏洞\n\n Args:\n ...]
n4[logger.info(&#39;fixing_vulnerability&...]
n5[fix_id = hashlib.sha256(f&#39;{co...]
n6[result = {&#39;fix_id&#39;: fix_id, ...]
n7[try]
n8{if self.use_litellm or (OPENAI...}
n9[fixed = self._fix_with_llm(c...]
n10[result.update(fixed)]
n11[fixed = self._fix_with_mock(...]
n12[result.update(fixed)]
n13[]
n14[result[&#39;status&#39;] = &&...]
n15[logger.info(&#39;vulnerability_fixed&#...]
n16[]
n17[except Exception]
n18[logger.error(&#39;fix_failed&#39;, fi...]
n19[result[&#39;status&#39;] = &&...]
n20[result[&#39;error&#39;] = str(...]
n21[self.fix_history.append(result)]
n22[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n17
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n21
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n16
n21 --> n22
n22 --> n2
995. integration aiva integration remediation code fixer Function get fix history
flowchart TB
n1([開始])
n2([結束])
n3['獲取修復歷史']
n4[return self.fix_history]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取修復歷史&#39;]
n4[return self.fix_history]
n1 --> n3
n3 --> n4
n4 --> n2
996. integration aiva integration remediation code fixer Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例 - Mock 模式']
n4[print('🤖 Code Fixer Demo (Mock Mode...]
n5[print('=' * 60)]
n6[fixer = CodeFixer(use_litell...]
n7[sql_code = 'cursor.execute("SEL...]
n8[result1 = fixer.fix_vulnerabil...]
n9[print('\n📋 SQL Injection Fix:'...]
n10[print(f" Status: {result1[&...]
n11[print(f" Confidence: {result1[&am...]
n12[print(f" Explanation: {result1[&a...]
n13[xss_code = "return render_templ...]
n14[result2 = fixer.fix_vulnerabil...]
n15[print('\n📋 XSS Fix:')]
n16[print(f" Status: {result2[&...]
n17[print(f" Confidence: {result2[&am...]
n18[print('\n✅ Demo completed (Mock mode&...]
n19[print('💡 Provide API key to use real LLM ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例 - Mock 模式&#39;]
n4[print(&#39;🤖 Code Fixer Demo (Mock Mode&#...]
n5[print(&#39;=&#39; * 60)]
n6[fixer = CodeFixer(use_litell...]
n7[sql_code = &#39;cursor.execute(&quot;SEL...]
n8[result1 = fixer.fix_vulnerabil...]
n9[print(&#39;\n📋 SQL Injection Fix:&#39...]
n10[print(f&quot; Status: {result1[&&#...]
n11[print(f&quot; Confidence: {result1[&am...]
n12[print(f&quot; Explanation: {result1[&a...]
n13[xss_code = &quot;return render_templ...]
n14[result2 = fixer.fix_vulnerabil...]
n15[print(&#39;\n📋 XSS Fix:&#39;)]
n16[print(f&quot; Status: {result2[&&#...]
n17[print(f&quot; Confidence: {result2[&am...]
n18[print(&#39;\n✅ Demo completed (Mock mode&...]
n19[print(&#39;💡 Provide API key to use real LLM ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
997. integration aiva integration remediation config recommender Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化配置建議器\n\n Args:\n ...]
n4[self.preserve_comments = preserve_comments]
n5[self.yaml = YAML()]
n6{if preserve_comments}
n7[self.yaml.preserve_quotes = True]
n8[self.yaml.default_flow_style = False]
n9[]
n10[self.recommendations: list[dict[str, Any]]...]
n11[logger.info('config_recommender_initializ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化配置建議器\n\n Args:\n ...]
n4[self.preserve_comments = preserve_comments]
n5[self.yaml = YAML()]
n6{if preserve_comments}
n7[self.yaml.preserve_quotes = True]
n8[self.yaml.default_flow_style = False]
n9[]
n10[self.recommendations: list[dict[str, Any]]...]
n11[logger.info(&#39;config_recommender_initializ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
998. integration aiva integration remediation config recommender Function analyze application config
flowchart TB
n1([開始])
n2([結束])
n3['分析應用程序配置']
n4{if config.get('debug', False&...}
n5[analysis['issues'].append...]
n6[analysis['recommendations' ...]
n7[]
n8[secret_key = config.get('secret_k...]
n9{if not secret_key or secret_ke...}
n10[analysis['issues'].append...]
n11[analysis['recommendations' ...]
n12[]
n13[cors_origins = config.get('cors&#...]
n14{if '*' in cors_origins}
n15[analysis['issues'].append...]
n16[analysis['recommendations' ...]
n17[]
n18[return analysis]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析應用程序配置&#39;]
n4{if config.get(&#39;debug&#39;, False&...}
n5[analysis[&#39;issues&#39;].append...]
n6[analysis[&#39;recommendations&#39;	...]
n7[]
n8[secret_key = config.get(&#39;secret_k...]
n9{if not secret_key or secret_ke...}
n10[analysis[&#39;issues&#39;].append...]
n11[analysis[&#39;recommendations&#39;	...]
n12[]
n13[cors_origins = config.get(&#39;cors&#...]
n14{if &#39;*&#39; in cors_origins}
n15[analysis[&#39;issues&#39;].append...]
n16[analysis[&#39;recommendations&#39;	...]
n17[]
n18[return analysis]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
999. integration aiva integration remediation config recommender Function analyze database config
flowchart TB
n1([開始])
n2([結束])
n3['分析數據庫配置']
n4{if not config.get('ssl', ...}
n5[analysis['issues'].append...]
n6[analysis['recommendations' ...]
n7[]
n8[default_ports = {'mysql': 33...]
n9[db_type = config.get('type', ...]
n10[current_port = config.get('port&#...]
n11{if db_type in default_ports an...}
n12[analysis['issues'].append...]
n13[analysis['recommendations' ...]
n14[]
n15{if not config.get('password_po...}
n16[analysis['recommendations' ...]
n17[]
n18[return analysis]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析數據庫配置&#39;]
n4{if not config.get(&#39;ssl&#39;, ...}
n5[analysis[&#39;issues&#39;].append...]
n6[analysis[&#39;recommendations&#39;	...]
n7[]
n8[default_ports = {&#39;mysql&#39;: 33...]
n9[db_type = config.get(&#39;type&#39;, ...]
n10[current_port = config.get(&#39;port&#...]
n11{if db_type in default_ports an...}
n12[analysis[&#39;issues&#39;].append...]
n13[analysis[&#39;recommendations&#39;	...]
n14[]
n15{if not config.get(&#39;password_po...}
n16[analysis[&#39;recommendations&#39;	...]
n17[]
n18[return analysis]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
1000. integration aiva integration remediation config recommender Function analyze general config
flowchart TB
n1([開始])
n2([結束])
n3['分析通用配置']
n4[log_level = config.get('logging&#...]
n5{if log_level in ['DEBUG', &am...}
n6[analysis['recommendations' ...]
n7[]
n8[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析通用配置&#39;]
n4[log_level = config.get(&#39;logging&#...]
n5{if log_level in [&#39;DEBUG&#39;, &am...}
n6[analysis[&#39;recommendations&#39;	...]
n7[]
n8[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1001. integration aiva integration remediation config recommender Function analyze web server config
flowchart TB
n1([開始])
n2([結束])
n3['分析 Web 服務器配置']
n4{if not config.get('https', ...}
n5[analysis['issues'].append...]
n6[analysis['recommendations' ...]
n7[]
n8{if not config.get('security_he...}
n9[analysis['issues'].append...]
n10[analysis['recommendations' ...]
n11[]
n12{if not config.get('security_he...}
n13[analysis['issues'].append...]
n14[analysis['recommendations' ...]
n15[]
n16[return analysis]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析 Web 服務器配置&#39;]
n4{if not config.get(&#39;https&#39;, &#...}
n5[analysis[&#39;issues&#39;].append...]
n6[analysis[&#39;recommendations&#39;	...]
n7[]
n8{if not config.get(&#39;security_he...}
n9[analysis[&#39;issues&#39;].append...]
n10[analysis[&#39;recommendations&#39;	...]
n11[]
n12{if not config.get(&#39;security_he...}
n13[analysis[&#39;issues&#39;].append...]
n14[analysis[&#39;recommendations&#39;	...]
n15[]
n16[return analysis]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1002. integration aiva integration remediation config recommender Function calculate risk level
flowchart TB
n1([開始])
n2([結束])
n3['計算整體風險等級']
n4{if not issues}
n5[return 'LOW']
n6[]
n7[severity_scores = {'CRITICAL'...]
n8[total_score = sum((severity_scores...]
n9{if total_score >= 10}
n10[return 'CRITICAL']
n11[]
n12{if total_score >= 7}
n13[return 'HIGH']
n14[]
n15{if total_score >= 4}
n16[return 'MEDIUM']
n17[]
n18[return 'LOW']
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算整體風險等級&#39;]
n4{if not issues}
n5[return &#39;LOW&#39;]
n6[]
n7[severity_scores = {&#39;CRITICAL&#39...]
n8[total_score = sum((severity_scores...]
n9{if total_score &gt;= 10}
n10[return &#39;CRITICAL&#39;]
n11[]
n12{if total_score &gt;= 7}
n13[return &#39;HIGH&#39;]
n14[]
n15{if total_score &gt;= 4}
n16[return &#39;MEDIUM&#39;]
n17[]
n18[return &#39;LOW&#39;]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 --> n2
1003. integration aiva integration remediation config recommender Function analyze security config
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析安全配置\n\n Args:\n ...]
n4[logger.info('analyzing_config'...]
n5[analysis = {'analysis_id': h...]
n6{if config_type == 'web_server'}
n7[analysis = self._analyze_web_se...]
n8{if config_type == 'database'}
n9[analysis = self._analyze_databa...]
n10{if config_type == 'application'}
n11[analysis = self._analyze_applic...]
n12[analysis = self._analyze_genera...]
n13[]
n14[]
n15[]
n16[analysis['risk_level'] = ...]
n17[self.recommendations.append(analysis)]
n18[logger.info('config_analyzed'...]
n19[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析安全配置\n\n Args:\n ...]
n4[logger.info(&#39;analyzing_config&#39...]
n5[analysis = {&#39;analysis_id&#39;: h...]
n6{if config_type == &#39;web_server&#39;}
n7[analysis = self._analyze_web_se...]
n8{if config_type == &#39;database&#39;}
n9[analysis = self._analyze_databa...]
n10{if config_type == &#39;application&#39;}
n11[analysis = self._analyze_applic...]
n12[analysis = self._analyze_genera...]
n13[]
n14[]
n15[]
n16[analysis[&#39;risk_level&#39;] = ...]
n17[self.recommendations.append(analysis)]
n18[logger.info(&#39;config_analyzed&#39;...]
n19[return analysis]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
1004. integration aiva integration remediation config recommender Function export recommendations to yaml
flowchart TB
n1([開始])
n2([結束])
n3['\n 導出建議到 YAML 文件\n\n Args:\n ...]
n4[path = Path(output_path)]
n5[try]
n6[with open(path...]
n7[self.yaml.dump({'analysis_id&...]
n8[logger.info('recommendations_exported&...]
n9[return {'success': True, &am...]
n10[]
n11[except Exception]
n12[logger.error('export_failed',...]
n13[return {'success': False, &a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n11
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
n11 --> n12
n12 --> n13
n13 --> n10
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 導出建議到 YAML 文件\n\n Args:\n ...]
n4[path = Path(output_path)]
n5[try]
n6[with open(path...]
n7[self.yaml.dump({&#39;analysis_id&...]
n8[logger.info(&#39;recommendations_exported&...]
n9[return {&#39;success&#39;: True, &am...]
n10[]
n11[except Exception]
n12[logger.error(&#39;export_failed&#39;,...]
n13[return {&#39;success&#39;: False, &a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n11
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
n11 --> n12
n12 --> n13
n13 --> n10
1005. integration aiva integration remediation config recommender Function generate secure config
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據建議生成安全配置\n\n Args:\n ...]
n4[logger.info('generating_secure_config&...]
n5[secure_config = base_config.copy()]
n6{for rec in analysis['recomme...}
n7[keys = rec['key'].split...]
n8[current = secure_config]
n9{for key in keys[:-1]}
n10{if key not in current}
n11[current[key] = {}]
n12[]
n13[current = current[key]]
n14[]
n15[current[keys[-1]] = rec['...]
n16[]
n17[logger.info('secure_config_generated&...]
n18[return secure_config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n9
n14 --> n15
n15 --> n6
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據建議生成安全配置\n\n Args:\n ...]
n4[logger.info(&#39;generating_secure_config&...]
n5[secure_config = base_config.copy()]
n6{for rec in analysis[&#39;recomme...}
n7[keys = rec[&#39;key&#39;].split&#...]
n8[current = secure_config]
n9{for key in keys[:-1]}
n10{if key not in current}
n11[current[key] = {}]
n12[]
n13[current = current[key]]
n14[]
n15[current[keys[-1]] = rec[&#39;...]
n16[]
n17[logger.info(&#39;secure_config_generated&...]
n18[return secure_config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n16
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n9
n14 --> n15
n15 --> n6
n16 --> n17
n17 --> n18
n18 --> n2
1006. integration aiva integration remediation config recommender Function get recommendations
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有建議']
n4[return self.recommendations]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有建議&#39;]
n4[return self.recommendations]
n1 --> n3
n3 --> n4
n4 --> n2
1007. integration aiva integration remediation config recommender Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[print('⚙️ Config Recommender Demo&...]
n5[print('=' * 60)]
n6[recommender = ConfigRecommender()]
n7[web_config = {'https': {...]
n8[analysis = recommender.analyze_...]
n9[print(f"\n📊 Analysis ID: {analysis[...]
n10[print(f"🎯 Config Type: {analysis[&a...]
n11[print(f"⚠️ Risk Level: {analysis[&...]
n12[print(f"\n🔍 Issues Found: {len(anal...]
n13{for issue in analysis['issues'...}
n14[print(f" - [{issue[&#...]
n15[]
n16[print(f"\n💡 Recommendations: {len(a...]
n17{for rec in analysis['recomme...}
n18[print(f" - {rec['key&...]
n19[print(f" Reason: {rec[&#...]
n20[]
n21[secure_config = recommender.generate...]
n22[print('\n✅ Secure config generated&...]
n23[print(f" HTTPS enabled: {secure_confi...]
n24[print('\n✅ Demo completed')]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n13
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n17
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[print(&#39;⚙️ Config Recommender Demo&&#...]
n5[print(&#39;=&#39; * 60)]
n6[recommender = ConfigRecommender()]
n7[web_config = {&#39;https&#39;: {...]
n8[analysis = recommender.analyze_...]
n9[print(f&quot;\n📊 Analysis ID: {analysis[...]
n10[print(f&quot;🎯 Config Type: {analysis[&a...]
n11[print(f&quot;⚠️ Risk Level: {analysis[&...]
n12[print(f&quot;\n🔍 Issues Found: {len(anal...]
n13{for issue in analysis[&#39;issues&#39...}
n14[print(f&quot; - [{issue[&#...]
n15[]
n16[print(f&quot;\n💡 Recommendations: {len(a...]
n17{for rec in analysis[&#39;recomme...}
n18[print(f&quot; - {rec[&#39;key&...]
n19[print(f&quot; Reason: {rec[&#...]
n20[]
n21[secure_config = recommender.generate...]
n22[print(&#39;\n✅ Secure config generated&&#...]
n23[print(f&quot; HTTPS enabled: {secure_confi...]
n24[print(&#39;\n✅ Demo completed&#39;)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n13
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n20
n18 --> n19
n19 --> n17
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n2
1008. integration aiva integration remediation patch generator Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化補丁生成器\n\n Args:\n ...]
n4[self.repo_path = Path(repo_path) if r...]
n5[self.auto_commit = auto_commit]
n6[self.repo: git.Repo | None = None]
n7[self.patches: list[dict[str, Any]] = [...]
n8{if self.repo_path and self.rep...}
n9[try]
n10[self.repo = git.Repo(self.repo_p...]
n11[logger.info('patch_generator_initialized&...]
n12[]
n13[except git.exc.Inva...]
n14[logger.warning('invalid_git_repo&#...]
n15[logger.info('patch_generator_initialized&...]
n16[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n15
n9 --> n10
n9 --> n13
n10 --> n11
n11 --> n12
n12 --> n16
n13 --> n14
n14 --> n12
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化補丁生成器\n\n Args:\n ...]
n4[self.repo_path = Path(repo_path) if r...]
n5[self.auto_commit = auto_commit]
n6[self.repo: git.Repo | None = None]
n7[self.patches: list[dict[str, Any]] = [...]
n8{if self.repo_path and self.rep...}
n9[try]
n10[self.repo = git.Repo(self.repo_p...]
n11[logger.info(&#39;patch_generator_initialized&...]
n12[]
n13[except git.exc.Inva...]
n14[logger.warning(&#39;invalid_git_repo&#...]
n15[logger.info(&#39;patch_generator_initialized&...]
n16[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n15
n9 --> n10
n9 --> n13
n10 --> n11
n11 --> n12
n12 --> n16
n13 --> n14
n14 --> n12
n15 --> n16
n16 --> n2
1009. integration aiva integration remediation patch generator Function generate git diff
flowchart TB
n1([開始])
n2([結束])
n3['使用 Git 生成差異']
n4{if not self.repo}
n5[return '']
n6[]
n7[return f'# Git diff would be generate...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;使用 Git 生成差異&#39;]
n4{if not self.repo}
n5[return &#39;&#39;]
n6[]
n7[return f&#39;# Git diff would be generate...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1010. integration aiva integration remediation patch generator Function generate simple patch
flowchart TB
n1([開始])
n2([結束])
n3['生成簡單的補丁格式']
n4[return f'--- a/{file_path}\n+++ b/&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成簡單的補丁格式&#39;]
n4[return f&#39;--- a/{file_path}\n+++ b/&...]
n1 --> n3
n3 --> n4
n4 --> n2
1011. integration aiva integration remediation patch generator Function suggest html escape
flowchart TB
n1([開始])
n2([結束])
n3['建議 HTML 轉義']
n4{if 'render(' in vulnerable_co...}
n5[return f'html.escape({vulnerable_cod...]
n6[]
n7[return f'html.escape({vulnerable_cod...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;建議 HTML 轉義&#39;]
n4{if &#39;render(&#39; in vulnerable_co...}
n5[return f&#39;html.escape({vulnerable_cod...]
n6[]
n7[return f&#39;html.escape({vulnerable_cod...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1012. integration aiva integration remediation patch generator Function suggest parameterized query
flowchart TB
n1([開始])
n2([結束])
n3['建議參數化查詢']
n4{if 'execute(' in vulnerable_c...}
n5[return vulnerable_code.replace('execu...]
n6[]
n7[return f'{vulnerable_code} # TO...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;建議參數化查詢&#39;]
n4{if &#39;execute(&#39; in vulnerable_c...}
n5[return vulnerable_code.replace(&#39;execu...]
n6[]
n7[return f&#39;{vulnerable_code} # TO...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1013. integration aiva integration remediation patch generator Function apply patch
flowchart TB
n1([開始])
n2([結束])
n3['\n 應用補丁\n\n Args:\n ...]
n4[patch = next((p for p in sel...]
n5{if not patch}
n6[return {'success': False, &a...]
n7[]
n8[logger.info('applying_patch',...]
n9{if not self.repo}
n10[return {'success': False, &a...]
n11[]
n12[try]
n13[result = {'success': True, &...]
n14{if self.auto_commit}
n15[result['committed'] = True]
n16[result['commit_hash'] = &...]
n17[]
n18[patch['status'] = &...]
n19[logger.info('patch_applied', ...]
n20[return result]
n21[]
n22[except Exception]
n23[logger.error('patch_apply_failed&#...]
n24[patch['status'] = &...]
n25[return {'success': False, &a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n12 --> n22
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n21
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 應用補丁\n\n Args:\n ...]
n4[patch = next((p for p in sel...]
n5{if not patch}
n6[return {&#39;success&#39;: False, &a...]
n7[]
n8[logger.info(&#39;applying_patch&#39;,...]
n9{if not self.repo}
n10[return {&#39;success&#39;: False, &a...]
n11[]
n12[try]
n13[result = {&#39;success&#39;: True, &...]
n14{if self.auto_commit}
n15[result[&#39;committed&#39;] = True]
n16[result[&#39;commit_hash&#39;] = &...]
n17[]
n18[patch[&#39;status&#39;] = &&#...]
n19[logger.info(&#39;patch_applied&#39;, ...]
n20[return result]
n21[]
n22[except Exception]
n23[logger.error(&#39;patch_apply_failed&#...]
n24[patch[&#39;status&#39;] = &&#...]
n25[return {&#39;success&#39;: False, &a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n12 --> n22
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n2
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n21
1014. integration aiva integration remediation patch generator Function export patches
flowchart TB
n1([開始])
n2([結束])
n3['\n 導出所有補丁到目錄\n\n Args:\n ...]
n4[output_path = Path(output_dir)]
n5[output_path.mkdir(parents=True, exist_ok=True)]
n6[exported = []]
n7{for patch in self.patches}
n8[patch_file = output_path / f"{pat...]
n9[try]
n10[patch_file.write_text(f"Patch ID: {patc...]
n11[exported.append(str(patch_file))]
n12[logger.info('patch_exported',...]
n13[]
n14[except Exception]
n15[logger.error('patch_export_failed&...]
n16[]
n17[return {'success': True, &am...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n16
n8 --> n9
n9 --> n10
n9 --> n14
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n7
n14 --> n15
n15 --> n13
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 導出所有補丁到目錄\n\n Args:\n ...]
n4[output_path = Path(output_dir)]
n5[output_path.mkdir(parents=True, exist_ok=True)]
n6[exported = []]
n7{for patch in self.patches}
n8[patch_file = output_path / f&quot;{pat...]
n9[try]
n10[patch_file.write_text(f&quot;Patch ID: {patc...]
n11[exported.append(str(patch_file))]
n12[logger.info(&#39;patch_exported&#39;,...]
n13[]
n14[except Exception]
n15[logger.error(&#39;patch_export_failed&...]
n16[]
n17[return {&#39;success&#39;: True, &am...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n16
n8 --> n9
n9 --> n10
n9 --> n14
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n7
n14 --> n15
n15 --> n13
n16 --> n17
n17 --> n2
1015. integration aiva integration remediation patch generator Function generate patch for vulnerability
flowchart TB
n1([開始])
n2([結束])
n3['\n 為特定漏洞生成補丁\n\n Args:\n ...]
n4[logger.info('generating_patch'...]
n5[patch = {'patch_id': hashlib...]
n6{if self.repo}
n7[try]
n8[patch['diff'] = self._gen...]
n9[patch['status'] = &...]
n10[]
n11[except Exception]
n12[logger.error('git_diff_failed'...]
n13[patch['error'] = str(...]
n14[patch['status'] = &...]
n15[patch['diff'] = self._gen...]
n16[]
n17[self.patches.append(patch)]
n18[logger.info('patch_generated'...]
n19[return patch]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n15
n7 --> n8
n7 --> n11
n8 --> n9
n9 --> n10
n10 --> n16
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n10
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 為特定漏洞生成補丁\n\n Args:\n ...]
n4[logger.info(&#39;generating_patch&#39...]
n5[patch = {&#39;patch_id&#39;: hashlib...]
n6{if self.repo}
n7[try]
n8[patch[&#39;diff&#39;] = self._gen...]
n9[patch[&#39;status&#39;] = &&#...]
n10[]
n11[except Exception]
n12[logger.error(&#39;git_diff_failed&#39...]
n13[patch[&#39;error&#39;] = str(...]
n14[patch[&#39;status&#39;] = &&#...]
n15[patch[&#39;diff&#39;] = self._gen...]
n16[]
n17[self.patches.append(patch)]
n18[logger.info(&#39;patch_generated&#39;...]
n19[return patch]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n15
n7 --> n8
n7 --> n11
n8 --> n9
n9 --> n10
n10 --> n16
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n10
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
1016. integration aiva integration remediation patch generator Function generate sql injection patch
flowchart TB
n1([開始])
n2([結束])
n3['\n 為 SQL 注入漏洞生成補丁\n\n Args:\n ...]
n4[suggested_fix = self._suggest_parame...]
n5[return self.generate_patch_for_vulner...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 為 SQL 注入漏洞生成補丁\n\n Args:\n ...]
n4[suggested_fix = self._suggest_parame...]
n5[return self.generate_patch_for_vulner...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1017. integration aiva integration remediation patch generator Function generate xss patch
flowchart TB
n1([開始])
n2([結束])
n3['\n 為 XSS 漏洞生成補丁\n\n Args:\n ...]
n4[suggested_fix = self._suggest_html_e...]
n5[return self.generate_patch_for_vulner...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 為 XSS 漏洞生成補丁\n\n Args:\n ...]
n4[suggested_fix = self._suggest_html_e...]
n5[return self.generate_patch_for_vulner...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1018. integration aiva integration remediation patch generator Function get patches
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有補丁']
n4[return self.patches]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有補丁&#39;]
n4[return self.patches]
n1 --> n3
n3 --> n4
n4 --> n2
1019. integration aiva integration remediation patch generator Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[print('🔧 Patch Generator Demo'...]
n5[print('=' * 60)]
n6[generator = PatchGenerator()]
n7[sql_patch = generator.generate_s...]
n8[print('\n📋 Generated SQL Injection Patch:...]
n9[print(f" Patch ID: {sql_patch[&am...]
n10[print(f" File: {sql_patch[&...]
n11[print(f" Status: {sql_patch[&...]
n12[xss_patch = generator.generate_x...]
n13[print('\n📋 Generated XSS Patch:&#...]
n14[print(f" Patch ID: {xss_patch[&am...]
n15[print(f" File: {xss_patch[&...]
n16[with tempfile....]
n17[result = generator.export_pat...]
n18[print(f"\n💾 Exported {result[&&...]
n19[print('\n✅ Demo completed')]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[print(&#39;🔧 Patch Generator Demo&#39...]
n5[print(&#39;=&#39; * 60)]
n6[generator = PatchGenerator()]
n7[sql_patch = generator.generate_s...]
n8[print(&#39;\n📋 Generated SQL Injection Patch:...]
n9[print(f&quot; Patch ID: {sql_patch[&am...]
n10[print(f&quot; File: {sql_patch[&&#...]
n11[print(f&quot; Status: {sql_patch[&...]
n12[xss_patch = generator.generate_x...]
n13[print(&#39;\n📋 Generated XSS Patch:&#...]
n14[print(f&quot; Patch ID: {xss_patch[&am...]
n15[print(f&quot; File: {xss_patch[&&#...]
n16[with tempfile....]
n17[result = generator.export_pat...]
n18[print(f&quot;\n💾 Exported {result[&&...]
n19[print(&#39;\n✅ Demo completed&#39;)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
1020. integration aiva integration remediation report generator Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化報告生成器\n\n Args:\n ...]
n4[self.output_dir = Path(output_dir)]
n5[self.output_dir.mkdir(parents=True, exist_ok=True)]
n6{if template_dir and Path(templ...}
n7[self.jinja_env = Environment(loader=F...]
n8[logger.info('report_generator_initialized...]
n9[self.jinja_env = None]
n10[logger.info('report_generator_initialized...]
n11[]
n12[self.reports: list[dict[str, Any]] = [...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化報告生成器\n\n Args:\n ...]
n4[self.output_dir = Path(output_dir)]
n5[self.output_dir.mkdir(parents=True, exist_ok=True)]
n6{if template_dir and Path(templ...}
n7[self.jinja_env = Environment(loader=F...]
n8[logger.info(&#39;report_generator_initialized...]
n9[self.jinja_env = None]
n10[logger.info(&#39;report_generator_initialized...]
n11[]
n12[self.reports: list[dict[str, Any]] = [...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
1021. integration aiva integration remediation report generator Function calculate fix statistics
flowchart TB
n1([開始])
n2([結束])
n3['計算修復統計']
n4[stats = {'total': len(fi...]
n5{for fix in fixes}
n6[status = fix.get('status', &a...]
n7{if status == 'completed'}
n8[stats['successful'] += 1]
n9{if status == 'failed'}
n10[stats['failed'] += 1]
n11[stats['pending'] += 1]
n12[]
n13[]
n14[]
n15[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n14
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n5
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算修復統計&#39;]
n4[stats = {&#39;total&#39;: len(fi...]
n5{for fix in fixes}
n6[status = fix.get(&#39;status&#39;, &a...]
n7{if status == &#39;completed&#39;}
n8[stats[&#39;successful&#39;] += 1]
n9{if status == &#39;failed&#39;}
n10[stats[&#39;failed&#39;] += 1]
n11[stats[&#39;pending&#39;] += 1]
n12[]
n13[]
n14[]
n15[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n14
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n5
n14 --> n15
n15 --> n2
1022. integration aiva integration remediation report generator Function calculate vuln statistics
flowchart TB
n1([開始])
n2([結束])
n3['計算漏洞統計']
n4[stats = {'total': len(vu...]
n5{for vuln in vulnerabilities}
n6[severity = vuln.get('severity'...]
n7[vuln_type = vuln.get('type', ...]
n8[stats['by_severity'][...]
n9[stats['by_type'][vuln...]
n10[]
n11[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;計算漏洞統計&#39;]
n4[stats = {&#39;total&#39;: len(vu...]
n5{for vuln in vulnerabilities}
n6[severity = vuln.get(&#39;severity&#39...]
n7[vuln_type = vuln.get(&#39;type&#39;, ...]
n8[stats[&#39;by_severity&#39;][...]
n9[stats[&#39;by_type&#39;][vuln...]
n10[]
n11[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
1023. integration aiva integration remediation report generator Function generate html report
flowchart TB
n1([開始])
n2([結束])
n3['生成 HTML 報告']
n4[output_file = self.output_dir / f"...]
n5{if self.jinja_env}
n6[try]
n7[template = self.jinja_env.get_t...]
n8[html_content = template.render(repo...]
n9[]
n10[except Exception]
n11[logger.warning('template_load_failed&...]
n12[html_content = self._generate_inlin...]
n13[html_content = self._generate_inlin...]
n14[]
n15[output_file.write_text(html_content, encoding=&...]
n16[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n6 --> n10
n7 --> n8
n8 --> n9
n9 --> n14
n10 --> n11
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 HTML 報告&#39;]
n4[output_file = self.output_dir / f&quot;...]
n5{if self.jinja_env}
n6[try]
n7[template = self.jinja_env.get_t...]
n8[html_content = template.render(repo...]
n9[]
n10[except Exception]
n11[logger.warning(&#39;template_load_failed&...]
n12[html_content = self._generate_inlin...]
n13[html_content = self._generate_inlin...]
n14[]
n15[output_file.write_text(html_content, encoding=&&#...]
n16[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n6 --> n10
n7 --> n8
n8 --> n9
n9 --> n14
n10 --> n11
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1024. integration aiva integration remediation report generator Function generate inline html
flowchart TB
n1([開始])
n2([結束])
n3['生成內置 HTML 模板']
n4[stats = report['statistics']]
n5[vulns = report['vulnerabilit...]
n6[html = f"""<!DOCTYPE ht...]
n7{for severity in ['CRITICAL', ...}
n8[count = stats['by_severity'...]
n9{if count > 0}
n10[html += f'\n <div class=&am...]
n11[]
n12[]
n13[html += '\n </div>\n\n ...]
n14{for vuln in vulns}
n15[severity = vuln.get('severity'...]
n16[title = vuln.get('title', &am...]
n17[vuln_type = vuln.get('type', ...]
n18[location = vuln.get('location'...]
n19[html += f'\n <div class=&qu...]
n20[]
n21[html += f"""\n <...]
n22[return html]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n14
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成內置 HTML 模板&#39;]
n4[stats = report[&#39;statistics&#39;]]
n5[vulns = report[&#39;vulnerabilit...]
n6[html = f&quot;&quot;&quot;&lt;!DOCTYPE ht...]
n7{for severity in [&#39;CRITICAL&#39;, ...}
n8[count = stats[&#39;by_severity&#39;&#...]
n9{if count &gt; 0}
n10[html += f&#39;\n &lt;div class=&am...]
n11[]
n12[]
n13[html += &#39;\n &lt;/div&gt;\n\n ...]
n14{for vuln in vulns}
n15[severity = vuln.get(&#39;severity&#39...]
n16[title = vuln.get(&#39;title&#39;, &am...]
n17[vuln_type = vuln.get(&#39;type&#39;, ...]
n18[location = vuln.get(&#39;location&#39...]
n19[html += f&#39;\n &lt;div class=&qu...]
n20[]
n21[html += f&quot;&quot;&quot;\n &lt;...]
n22[return html]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n14
n20 --> n21
n21 --> n22
n22 --> n2
1025. integration aiva integration remediation report generator Function generate markdown report
flowchart TB
n1([開始])
n2([結束])
n3['生成 Markdown 報告']
n4[output_file = self.output_dir / f"...]
n5[stats = report['statistics']]
n6[vulns = report['vulnerabilit...]
n7[md = f"# 🔒 Vulnerability ...]
n8{for (severity, count) in stats['b...}
n9[md += f'- **{severity}:** {cou...]
n10[]
n11[md += '\n## 🔍 Vulnerabilities\n\n&...]
n12{for vuln in vulns}
n13[severity = vuln.get('severity'...]
n14[title = vuln.get('title', &am...]
n15[vuln_type = vuln.get('type', ...]
n16[location = vuln.get('location'...]
n17[md += f'### [{severity...]
n18[]
n19[output_file.write_text(md, encoding='utf-...]
n20[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n18
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n12
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 Markdown 報告&#39;]
n4[output_file = self.output_dir / f&quot;...]
n5[stats = report[&#39;statistics&#39;]]
n6[vulns = report[&#39;vulnerabilit...]
n7[md = f&quot;# 🔒 Vulnerability ...]
n8{for (severity, count) in stats[&#39;b...}
n9[md += f&#39;- **{severity}:** {cou...]
n10[]
n11[md += &#39;\n## 🔍 Vulnerabilities\n\n&...]
n12{for vuln in vulns}
n13[severity = vuln.get(&#39;severity&#39...]
n14[title = vuln.get(&#39;title&#39;, &am...]
n15[vuln_type = vuln.get(&#39;type&#39;, ...]
n16[location = vuln.get(&#39;location&#39...]
n17[md += f&#39;### [{severity&#...]
n18[]
n19[output_file.write_text(md, encoding=&#39;utf-...]
n20[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n18
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n12
n18 --> n19
n19 --> n20
n20 --> n2
1026. integration aiva integration remediation report generator Function generate pdf report
flowchart TB
n1([開始])
n2([結束])
n3['生成 PDF 報告']
n4[output_file = self.output_dir / f"...]
n5{if WEASYPRINT_AVAILABLE and We...}
n6[html_content = self._generate_inlin...]
n7[WeasyHTML(string=html_content).write_pdf(outp...]
n8[logger.info('pdf_generated_weasyprint&...]
n9{if REPORTLAB_AVAILABLE and Sim...}
n10[self._generate_reportlab_pdf(report, output_file)]
n11[logger.info('pdf_generated_reportlab&...]
n12[logger.warning('no_pdf_library...]
n13[return self._generate_html_report(rep...]
n14[]
n15[]
n16[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成 PDF 報告&#39;]
n4[output_file = self.output_dir / f&quot;...]
n5{if WEASYPRINT_AVAILABLE and We...}
n6[html_content = self._generate_inlin...]
n7[WeasyHTML(string=html_content).write_pdf(outp...]
n8[logger.info(&#39;pdf_generated_weasyprint&...]
n9{if REPORTLAB_AVAILABLE and Sim...}
n10[self._generate_reportlab_pdf(report, output_file)]
n11[logger.info(&#39;pdf_generated_reportlab&...]
n12[logger.warning(&#39;no_pdf_library&#3...]
n13[return self._generate_html_report(rep...]
n14[]
n15[]
n16[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n15
n9 -->|Yes| n10
n9 -->|No| n12
n10 --> n11
n11 --> n14
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1027. integration aiva integration remediation report generator Function generate remediation html
flowchart TB
n1([開始])
n2([結束])
n3['生成修復報告 HTML']
n4[output_file = self.output_dir / f"...]
n5[stats = report['statistics']]
n6[fixes = report['fixes']]
n7[html = f"""<!DOCTYPE ht...]
n8{for fix in fixes}
n9[fix_id = fix.get('fix_id', &a...]
n10[status = fix.get('status', &a...]
n11[html += f'\n <div class=&qu...]
n12[]
n13[html += '\n </div>\n<...]
n14[output_file.write_text(html, encoding='ut...]
n15[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成修復報告 HTML&#39;]
n4[output_file = self.output_dir / f&quot;...]
n5[stats = report[&#39;statistics&#39;]]
n6[fixes = report[&#39;fixes&#39;]]
n7[html = f&quot;&quot;&quot;&lt;!DOCTYPE ht...]
n8{for fix in fixes}
n9[fix_id = fix.get(&#39;fix_id&#39;, &a...]
n10[status = fix.get(&#39;status&#39;, &a...]
n11[html += f&#39;\n &lt;div class=&qu...]
n12[]
n13[html += &#39;\n &lt;/div&gt;\n&lt;...]
n14[output_file.write_text(html, encoding=&#39;ut...]
n15[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n8
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
1028. integration aiva integration remediation report generator Function generate remediation markdown
flowchart TB
n1([開始])
n2([結束])
n3['生成修復報告 Markdown']
n4[output_file = self.output_dir / f"...]
n5[stats = report['statistics']]
n6[md = f"# ✅ Remediation Re...]
n7{for fix in report['fixes']}
n8[md += f"- **{fix.get('fix_i...]
n9[]
n10[output_file.write_text(md, encoding='utf-...]
n11[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成修復報告 Markdown&#39;]
n4[output_file = self.output_dir / f&quot;...]
n5[stats = report[&#39;statistics&#39;]]
n6[md = f&quot;# ✅ Remediation Re...]
n7{for fix in report[&#39;fixes&#39;]}
n8[md += f&quot;- **{fix.get(&#39;fix_i...]
n9[]
n10[output_file.write_text(md, encoding=&#39;utf-...]
n11[return output_file]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n11
n11 --> n2
1029. integration aiva integration remediation report generator Function generate reportlab pdf
flowchart TB
n1([開始])
n2([結束])
n3['使用 ReportLab 生成 PDF']
n4{if not REPORTLAB_AVAILABLE}
n5[raise RuntimeError('ReportLab not availab...]
n6[]
n7[assert SimpleDocTemplate is not None]
n8[assert getSampleStyleSheet is not None]
n9[assert Paragraph is not None]
n10[assert Spacer is not None]
n11[assert letter is not None]
n12[doc = SimpleDocTemplate(st...]
n13[styles = getSampleStyleSheet(...]
n14[story = []]
n15[story.append(Paragraph('Vulnerability...]
n16[story.append(Spacer(1, 12))]
n17[story.append(Paragraph(f"Report ID: ...]
n18[story.append(Spacer(1, 12))]
n19[stats = report['statistics']]
n20[story.append(Paragraph(f"Total Vulnerabi...]
n21[story.append(Spacer(1, 12))]
n22{for vuln in report['vulnerabi...}
n23[story.append(Paragraph(f"{vuln.get&...]
n24[story.append(Paragraph(f"Type: {vul...]
n25[story.append(Spacer(1, 6))]
n26[]
n27[doc.build(story)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n26
n23 --> n24
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;使用 ReportLab 生成 PDF&#39;]
n4{if not REPORTLAB_AVAILABLE}
n5[raise RuntimeError(&#39;ReportLab not availab...]
n6[]
n7[assert SimpleDocTemplate is not None]
n8[assert getSampleStyleSheet is not None]
n9[assert Paragraph is not None]
n10[assert Spacer is not None]
n11[assert letter is not None]
n12[doc = SimpleDocTemplate(st...]
n13[styles = getSampleStyleSheet(...]
n14[story = []]
n15[story.append(Paragraph(&#39;Vulnerability...]
n16[story.append(Spacer(1, 12))]
n17[story.append(Paragraph(f&quot;Report ID: ...]
n18[story.append(Spacer(1, 12))]
n19[stats = report[&#39;statistics&#39;]]
n20[story.append(Paragraph(f&quot;Total Vulnerabi...]
n21[story.append(Spacer(1, 12))]
n22{for vuln in report[&#39;vulnerabi...}
n23[story.append(Paragraph(f&quot;{vuln.get&...]
n24[story.append(Paragraph(f&quot;Type: {vul...]
n25[story.append(Spacer(1, 6))]
n26[]
n27[doc.build(story)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n26
n23 --> n24
n24 --> n25
n25 --> n22
n26 --> n27
n27 --> n2
1030. integration aiva integration remediation report generator Function generate remediation report
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成修復報告\n\n Args:\n ...]
n4[logger.info('generating_remediation_repor...]
n5[report_id = hashlib.sha256(f'rem...]
n6[report = {'report_id': repor...]
n7{if format == 'html'}
n8[output_file = self._generate_remed...]
n9{if format == 'markdown'}
n10[output_file = self._generate_remed...]
n11[output_file = self._generate_remed...]
n12[]
n13[]
n14[report['output_file'] = s...]
n15[report['success'] = True]
n16[self.reports.append(report)]
n17[logger.info('remediation_report_generated...]
n18[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成修復報告\n\n Args:\n ...]
n4[logger.info(&#39;generating_remediation_repor...]
n5[report_id = hashlib.sha256(f&#39;rem...]
n6[report = {&#39;report_id&#39;: repor...]
n7{if format == &#39;html&#39;}
n8[output_file = self._generate_remed...]
n9{if format == &#39;markdown&#39;}
n10[output_file = self._generate_remed...]
n11[output_file = self._generate_remed...]
n12[]
n13[]
n14[report[&#39;output_file&#39;] = s...]
n15[report[&#39;success&#39;] = True]
n16[self.reports.append(report)]
n17[logger.info(&#39;remediation_report_generated...]
n18[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n13
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
1031. integration aiva integration remediation report generator Function generate vulnerability report
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成漏洞報告\n\n Args:\n ...]
n4[logger.info('generating_vulnerability_rep...]
n5[report_id = hashlib.sha256(f'vul...]
n6[report = {'report_id': repor...]
n7{if format == 'html'}
n8[output_file = self._generate_html_...]
n9{if format == 'pdf'}
n10[output_file = self._generate_pdf_r...]
n11{if format == 'markdown'}
n12[output_file = self._generate_markd...]
n13[logger.error('unsupported_format&#...]
n14[return {'success': False, &a...]
n15[]
n16[]
n17[]
n18[report['output_file'] = s...]
n19[report['success'] = True]
n20[self.reports.append(report)]
n21[logger.info('vulnerability_report_generat...]
n22[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n17
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n16
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成漏洞報告\n\n Args:\n ...]
n4[logger.info(&#39;generating_vulnerability_rep...]
n5[report_id = hashlib.sha256(f&#39;vul...]
n6[report = {&#39;report_id&#39;: repor...]
n7{if format == &#39;html&#39;}
n8[output_file = self._generate_html_...]
n9{if format == &#39;pdf&#39;}
n10[output_file = self._generate_pdf_r...]
n11{if format == &#39;markdown&#39;}
n12[output_file = self._generate_markd...]
n13[logger.error(&#39;unsupported_format&#...]
n14[return {&#39;success&#39;: False, &a...]
n15[]
n16[]
n17[]
n18[report[&#39;output_file&#39;] = s...]
n19[report[&#39;success&#39;] = True]
n20[self.reports.append(report)]
n21[logger.info(&#39;vulnerability_report_generat...]
n22[return report]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n17
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n16
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n2
1032. integration aiva integration remediation report generator Function get reports
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有報告']
n4[return self.reports]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有報告&#39;]
n4[return self.reports]
n1 --> n3
n3 --> n4
n4 --> n2
1033. integration aiva integration remediation report generator Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[print('📄 Report Generator Demo...]
n5[print('=' * 60)]
n6[generator = ReportGenerator(outp...]
n7[test_vulns = [{'title': ...]
n8[report = generator.generate_v...]
n9[print('\n✅ Vulnerability report generated...]
n10[print(f" Report ID: {report[&...]
n11[print(f" File: {report[&#...]
n12[print(f" Total vulnerabilities: {repo...]
n13[print('\n✅ Demo completed')]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[print(&#39;📄 Report Generator Demo&#3...]
n5[print(&#39;=&#39; * 60)]
n6[generator = ReportGenerator(outp...]
n7[test_vulns = [{&#39;title&#39;: ...]
n8[report = generator.generate_v...]
n9[print(&#39;\n✅ Vulnerability report generated...]
n10[print(f&quot; Report ID: {report[&...]
n11[print(f&quot; File: {report[&#...]
n12[print(f&quot; Total vulnerabilities: {repo...]
n13[print(&#39;\n✅ Demo completed&#39;)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1034. integration aiva integration reporting formatter exporter Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._supported_formats = ['json&#...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._supported_formats = [&#39;json&#...]
n1 --> n3
n3 --> n2
1035. integration aiva integration reporting formatter exporter Function dict to xml
flowchart TB
n1([開始])
n2([結束])
n3['將字典轉換為 XML 行']
n4[lines = []]
n5[spaces = ' ' * indent]
n6{for (key, value) in data.items()}
n7[clean_key = key.replace(' ', ...]
n8{if isinstance(value, dict)}
n9[lines.append(f'{spaces}<...]
n10[lines.extend(self._dict_to_xml(value, indent + 2&...]
n11[lines.append(f'{spaces}<...]
n12{if isinstance(value, list)}
n13{for item in value}
n14{if isinstance(item, dict)}
n15[lines.append(f'{spaces}<...]
n16[lines.extend(self._dict_to_xml(item, indent + 2...]
n17[lines.append(f'{spaces}<...]
n18[lines.append(f'{spaces}<...]
n19[]
n20[]
n21[lines.append(f'{spaces}<...]
n22[]
n23[]
n24[]
n25[return lines]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n24
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n23
n12 -->|Yes| n13
n12 -->|No| n21
n13 -->|Yes| n14
n13 -->|No| n20
n14 -->|Yes| n15
n14 -->|No| n18
n15 --> n16
n16 --> n17
n17 --> n19
n18 --> n19
n19 --> n13
n20 --> n22
n21 --> n22
n22 --> n23
n23 --> n6
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將字典轉換為 XML 行&#39;]
n4[lines = []]
n5[spaces = &#39; &#39; * indent]
n6{for (key, value) in data.items()}
n7[clean_key = key.replace(&#39; &#39;, ...]
n8{if isinstance(value, dict)}
n9[lines.append(f&#39;{spaces}&lt;...]
n10[lines.extend(self._dict_to_xml(value, indent + 2&...]
n11[lines.append(f&#39;{spaces}&lt;...]
n12{if isinstance(value, list)}
n13{for item in value}
n14{if isinstance(item, dict)}
n15[lines.append(f&#39;{spaces}&lt;...]
n16[lines.extend(self._dict_to_xml(item, indent + 2&#...]
n17[lines.append(f&#39;{spaces}&lt;...]
n18[lines.append(f&#39;{spaces}&lt;...]
n19[]
n20[]
n21[lines.append(f&#39;{spaces}&lt;...]
n22[]
n23[]
n24[]
n25[return lines]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n24
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n23
n12 -->|Yes| n13
n12 -->|No| n21
n13 -->|Yes| n14
n13 -->|No| n20
n14 -->|Yes| n15
n14 -->|No| n18
n15 --> n16
n16 --> n17
n17 --> n19
n18 --> n19
n19 --> n13
n20 --> n22
n21 --> n22
n22 --> n23
n23 --> n6
n24 --> n25
n25 --> n2
1036. integration aiva integration reporting formatter exporter Function export csv
flowchart TB
n1([開始])
n2([結束])
n3['匯出為 CSV 格式(主要針對發現列表)']
n4[csv_lines = []]
n5[headers = ['Finding ID', &...]
n6[csv_lines.append(','.join(...]
n7[technical_details = content.get('technic...]
n8{for finding in technical_details}
n9[row = [finding.get('findin...]
n10[csv_lines.append(','.join(...]
n11[]
n12[return '\n'.join(csv_lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n8
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;匯出為 CSV 格式(主要針對發現列表)&#39;]
n4[csv_lines = []]
n5[headers = [&#39;Finding ID&#39;, &...]
n6[csv_lines.append(&#39;,&#39;.join(...]
n7[technical_details = content.get(&#39;technic...]
n8{for finding in technical_details}
n9[row = [finding.get(&#39;findin...]
n10[csv_lines.append(&#39;,&#39;.join(...]
n11[]
n12[return &#39;\n&#39;.join(csv_lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n8
n11 --> n12
n12 --> n2
1037. integration aiva integration reporting formatter exporter Function export html
flowchart TB
n1([開始])
n2([結束])
n3['匯出為 HTML 格式']
n4[html_parts = ['<!DOCTYPE html&...]
n5[exec_summary = content.get('executi...]
n6[html_parts.extend(['<h1>...]
n7[technical_details = content.get('technic...]
n8{if technical_details}
n9[html_parts.append('<h2>Tech...]
n10{for finding in technical_details...}
n11[severity = finding.get('severit...]
n12[html_parts.extend([f"<div class=&...]
n13[]
n14[]
n15[html_parts.extend(['</body&...]
n16[return '\n'.join(html_parts)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;匯出為 HTML 格式&#39;]
n4[html_parts = [&#39;&lt;!DOCTYPE html&...]
n5[exec_summary = content.get(&#39;executi...]
n6[html_parts.extend([&#39;&lt;h1&gt...]
n7[technical_details = content.get(&#39;technic...]
n8{if technical_details}
n9[html_parts.append(&#39;&lt;h2&gt;Tech...]
n10{for finding in technical_details...}
n11[severity = finding.get(&#39;severit...]
n12[html_parts.extend([f&quot;&lt;div class=&...]
n13[]
n14[]
n15[html_parts.extend([&#39;&lt;/body&...]
n16[return &#39;\n&#39;.join(html_parts)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n10
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1038. integration aiva integration reporting formatter exporter Function export json
flowchart TB
n1([開始])
n2([結束])
n3['匯出為 JSON 格式']
n4[return json.dumps(content, indent=2, ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;匯出為 JSON 格式&#39;]
n4[return json.dumps(content, indent=2, ...]
n1 --> n3
n3 --> n4
n4 --> n2
1039. integration aiva integration reporting formatter exporter Function export xml
flowchart TB
n1([開始])
n2([結束])
n3['匯出為 XML 格式']
n4[xml_lines = ['<?xml version=&q...]
n5[xml_lines.append('<SecurityReport&...]
n6[xml_lines.extend(self._dict_to_xml(content, inden...]
n7[xml_lines.append('</SecurityReport...]
n8[return '\n'.join(xml_lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;匯出為 XML 格式&#39;]
n4[xml_lines = [&#39;&lt;?xml version=&q...]
n5[xml_lines.append(&#39;&lt;SecurityReport&...]
n6[xml_lines.extend(self._dict_to_xml(content, inden...]
n7[xml_lines.append(&#39;&lt;/SecurityReport...]
n8[return &#39;\n&#39;.join(xml_lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1040. integration aiva integration reporting formatter exporter Function export to format
flowchart TB
n1([開始])
n2([結束])
n3['\n 將報告內容匯出為指定格式\n\n Args:\n ...]
n4[format_type = format_type.lower()]
n5{if format_type not in self._su...}
n6[raise ValueError(f'Unsupported format: ...]
n7[]
n8{if format_type == 'json'}
n9[return self._export_json(content)]
n10{if format_type == 'xml'}
n11[return self._export_xml(content)]
n12{if format_type == 'csv'}
n13[return self._export_csv(content)]
n14{if format_type == 'html'}
n15[return self._export_html(content)]
n16[raise ValueError(f'Format {format_ty...]
n17[]
n18[]
n19[]
n20[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n20
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n19
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n18
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將報告內容匯出為指定格式\n\n Args:\n ...]
n4[format_type = format_type.lower()]
n5{if format_type not in self._su...}
n6[raise ValueError(f&#39;Unsupported format: &#...]
n7[]
n8{if format_type == &#39;json&#39;}
n9[return self._export_json(content)]
n10{if format_type == &#39;xml&#39;}
n11[return self._export_xml(content)]
n12{if format_type == &#39;csv&#39;}
n13[return self._export_csv(content)]
n14{if format_type == &#39;html&#39;}
n15[return self._export_html(content)]
n16[raise ValueError(f&#39;Format {format_ty...]
n17[]
n18[]
n19[]
n20[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n20
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n19
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n18
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n2
1041. integration aiva integration reporting formatter exporter Function get supported formats
flowchart TB
n1([開始])
n2([結束])
n3['獲取支援的匯出格式']
n4[return self._supported_formats.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取支援的匯出格式&#39;]
n4[return self._supported_formats.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1042. integration aiva integration reporting report content generator Function init
flowchart TB
n1([開始])
n2([結束])
n3[pass]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[pass]
n1 --> n3
n3 --> n2
1043. integration aiva integration reporting report content generator Function extract risk factors
flowchart TB
n1([開始])
n2([結束])
n3['提取風險因素']
n4[factors = []]
n5[env_multiplier = risk_assessment.get(...]
n6{if env_multiplier > 1.5}
n7[factors.append('生產環境風險放大')]
n8[]
n9[severity_breakdown = risk_assessment.get(...]
n10{if severity_breakdown.get('cri...}
n11[factors.append('存在關鍵級別漏洞')]
n12[]
n13[return factors]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取風險因素&#39;]
n4[factors = []]
n5[env_multiplier = risk_assessment.get(...]
n6{if env_multiplier &gt; 1.5}
n7[factors.append(&#39;生產環境風險放大&#39;)]
n8[]
n9[severity_breakdown = risk_assessment.get(...]
n10{if severity_breakdown.get(&#39;cri...}
n11[factors.append(&#39;存在關鍵級別漏洞&#39;)]
n12[]
n13[return factors]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n2
1044. integration aiva integration reporting report content generator Function format compliance result
flowchart TB
n1([開始])
n2([結束])
n3['格式化合規結果']
n4{if not compliance_result}
n5[return {'message': &#...]
n6[]
n7[return {'policy': compliance...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;格式化合規結果&#39;]
n4{if not compliance_result}
n5[return {&#39;message&#39;: &#...]
n6[]
n7[return {&#39;policy&#39;: compliance...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1045. integration aiva integration reporting report content generator Function format correlation analysis
flowchart TB
n1([開始])
n2([結束])
n3['格式化相關性分析']
n4{if not correlation_analysis}
n5[return {'message': &#...]
n6[]
n7[return {'has_correlations': ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;格式化相關性分析&#39;]
n4{if not correlation_analysis}
n5[return {&#39;message&#39;: &#...]
n6[]
n7[return {&#39;has_correlations&#39;: ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1046. integration aiva integration reporting report content generator Function generate appendices
flowchart TB
n1([開始])
n2([結束])
n3['生成附錄']
n4[return {'vulnerability_classification...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成附錄&#39;]
n4[return {&#39;vulnerability_classification...]
n1 --> n3
n3 --> n4
n4 --> n2
1047. integration aiva integration reporting report content generator Function generate executive summary
flowchart TB
n1([開始])
n2([結束])
n3['生成執行摘要']
n4[total_findings = len(findings)]
n5[risk_level = risk_assessment.get(...]
n6[compliance_score = compliance_result.ge...]
n7[severity_counts: dict[str, int] = {}]
n8{for finding in findings}
n9[severity = finding.get('severit...]
n10[severity_counts[severity] = severity_counts.get...]
n11[]
n12[critical_count = severity_counts.get(...]
n13[high_count = severity_counts.get(...]
n14[key_findings = []]
n15{if critical_count > 0}
n16[key_findings.append(f'發現 {critical_c...]
n17[]
n18{if high_count > 0}
n19[key_findings.append(f'發現 {high_count...]
n20[]
n21{if compliance_score < 70}
n22[key_findings.append(f'合規分數偏低 ({c...]
n23[]
n24[risk_descriptions = {'critical&#...]
n25[return {'total_findings': to...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n8
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成執行摘要&#39;]
n4[total_findings = len(findings)]
n5[risk_level = risk_assessment.get(...]
n6[compliance_score = compliance_result.ge...]
n7[severity_counts: dict[str, int] = {}]
n8{for finding in findings}
n9[severity = finding.get(&#39;severit...]
n10[severity_counts[severity] = severity_counts.get&#...]
n11[]
n12[critical_count = severity_counts.get(...]
n13[high_count = severity_counts.get(...]
n14[key_findings = []]
n15{if critical_count &gt; 0}
n16[key_findings.append(f&#39;發現 {critical_c...]
n17[]
n18{if high_count &gt; 0}
n19[key_findings.append(f&#39;發現 {high_count...]
n20[]
n21{if compliance_score &lt; 70}
n22[key_findings.append(f&#39;合規分數偏低 ({c...]
n23[]
n24[risk_descriptions = {&#39;critical&#...]
n25[return {&#39;total_findings&#39;: to...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n11
n9 --> n10
n10 --> n8
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
1048. integration aiva integration reporting report content generator Function generate findings summary
flowchart TB
n1([開始])
n2([結束])
n3['生成發現摘要']
n4{if not findings}
n5[return {'message': &#...]
n6[]
n7[by_type: dict[str, int] = {}]
n8[by_severity: dict[str, int] = {}]
n9[by_location: dict[str, int] = {}]
n10{for finding in findings}
n11[vuln_type = finding.get('vulnera...]
n12[severity = finding.get('severit...]
n13[location = finding.get('locatio...]
n14[by_type[vuln_type] = by_type.get(vuln_typ...]
n15[by_severity[severity] = by_severity.get(seve...]
n16[by_location[location] = by_location.get(loca...]
n17[]
n18[return {'by_vulnerability_type&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n17
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n10
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成發現摘要&#39;]
n4{if not findings}
n5[return {&#39;message&#39;: &#...]
n6[]
n7[by_type: dict[str, int] = {}]
n8[by_severity: dict[str, int] = {}]
n9[by_location: dict[str, int] = {}]
n10{for finding in findings}
n11[vuln_type = finding.get(&#39;vulnera...]
n12[severity = finding.get(&#39;severit...]
n13[location = finding.get(&#39;locatio...]
n14[by_type[vuln_type] = by_type.get(vuln_typ...]
n15[by_severity[severity] = by_severity.get(seve...]
n16[by_location[location] = by_location.get(loca...]
n17[]
n18[return {&#39;by_vulnerability_type&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n17
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n10
n17 --> n18
n18 --> n2
1049. integration aiva integration reporting report content generator Function generate metadata
flowchart TB
n1([開始])
n2([結束])
n3['生成報告元數據']
n4[return {'report_id': f&q...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成報告元數據&#39;]
n4[return {&#39;report_id&#39;: f&q...]
n1 --> n3
n3 --> n4
n4 --> n2
1050. integration aiva integration reporting report content generator Function generate recommendations
flowchart TB
n1([開始])
n2([結束])
n3['生成修復建議']
n4[recommendations = []]
n5[risk_recommendations = risk_assessment.get(...]
n6{for rec in risk_recommendations}
n7[recommendations.append({'category&am...]
n8[]
n9[compliance_recommendations = compliance_result.ge...]
n10{for rec in compliance_recomm...}
n11[recommendations.append({'category&am...]
n12[]
n13{if findings}
n14[recommendations.append({'category&am...]
n15[]
n16[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成修復建議&#39;]
n4[recommendations = []]
n5[risk_recommendations = risk_assessment.get(...]
n6{for rec in risk_recommendations}
n7[recommendations.append({&#39;category&am...]
n8[]
n9[compliance_recommendations = compliance_result.ge...]
n10{for rec in compliance_recomm...}
n11[recommendations.append({&#39;category&am...]
n12[]
n13{if findings}
n14[recommendations.append({&#39;category&am...]
n15[]
n16[return recommendations]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n2
1051. integration aiva integration reporting report content generator Function generate risk overview
flowchart TB
n1([開始])
n2([結束])
n3['生成風險概覽']
n4[return {'overall_score': ris...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成風險概覽&#39;]
n4[return {&#39;overall_score&#39;: ris...]
n1 --> n3
n3 --> n4
n4 --> n2
1052. integration aiva integration reporting report content generator Function generate technical details
flowchart TB
n1([開始])
n2([結束])
n3['生成技術細節']
n4[technical_details = []]
n5{for finding in findings}
n6[detail = {'finding_id': find...]
n7[technical_details.append(detail)]
n8[]
n9[severity_order = {'critical'...]
n10[technical_details.sort(key=lambda x: severity_orde...]
n11[return technical_details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成技術細節&#39;]
n4[technical_details = []]
n5{for finding in findings}
n6[detail = {&#39;finding_id&#39;: find...]
n7[technical_details.append(detail)]
n8[]
n9[severity_order = {&#39;critical&#39;...]
n10[technical_details.sort(key=lambda x: severity_orde...]
n11[return technical_details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
1053. integration aiva integration reporting report content generator Function get highest severity
flowchart TB
n1([開始])
n2([結束])
n3['獲取最高嚴重性等級']
n4[severity_order = ['critical',...]
n5{for severity in severity_order}
n6{if by_severity.get(severity, 0...}
n7[return severity]
n8[]
n9[]
n10[return 'none']
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取最高嚴重性等級&#39;]
n4[severity_order = [&#39;critical&#39;,...]
n5{for severity in severity_order}
n6{if by_severity.get(severity, 0...}
n7[return severity]
n8[]
n9[]
n10[return &#39;none&#39;]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
1054. integration aiva integration reporting report content generator Function get severity definitions
flowchart TB
n1([開始])
n2([結束])
n3['獲取嚴重性等級定義']
n4[return {'critical': &...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取嚴重性等級定義&#39;]
n4[return {&#39;critical&#39;: &...]
n1 --> n3
n3 --> n4
n4 --> n2
1055. integration aiva integration reporting report content generator Function get vuln classifications
flowchart TB
n1([開始])
n2([結束])
n3['獲取漏洞分類說明']
n4[return {'xss': '...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取漏洞分類說明&#39;]
n4[return {&#39;xss&#39;: &#39;...]
n1 --> n3
n3 --> n4
n4 --> n2
1056. integration aiva integration reporting report content generator Function generate report content
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成完整的報告內容\n\n Args:\n ...]
n4[report_content = {'metadata'...]
n5[logger.info(f'Report content generated wi...]
n6[return report_content]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成完整的報告內容\n\n Args:\n ...]
n4[report_content = {&#39;metadata&#39;...]
n5[logger.info(f&#39;Report content generated wi...]
n6[return report_content]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1057. integration aiva integration reporting report template selector Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._templates = {'executive...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._templates = {&#39;executive&#3...]
n1 --> n3
n3 --> n2
1058. integration aiva integration reporting report template selector Function get available templates
flowchart TB
n1([開始])
n2([結束])
n3['獲取可用模板列表']
n4[return list(self._templates.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取可用模板列表&#39;]
n4[return list(self._templates.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
1059. integration aiva integration reporting report template selector Function select template
flowchart TB
n1([開始])
n2([結束])
n3['選擇報告模板']
n4[return self._templates.get(report_typ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;選擇報告模板&#39;]
n4[return self._templates.get(report_typ...]
n1 --> n3
n3 --> n4
n4 --> n2
1060. integration aiva integration security auth Function init
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(auto_error=False)]
n4[self.settings = settings]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(auto_error=False)]
n4[self.settings = settings]
n1 --> n3
n3 --> n4
n4 --> n2
1061. integration aiva integration settings Function load
flowchart TB
n1([開始])
n2([結束])
n3['從環境變數加載配置']
n4[cors_env = os.getenv('AIVA_CORS...]
n5[cors_origins = [s.strip() for s in ...]
n6[return cls(db_url=os.getenv('AIVA_DAT...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從環境變數加載配置&#39;]
n4[cors_env = os.getenv(&#39;AIVA_CORS...]
n5[cors_origins = [s.strip() for s in ...]
n6[return cls(db_url=os.getenv(&#39;AIVA_DAT...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1062. integration aiva integration settings Function use sql storage
flowchart TB
n1([開始])
n2([結束])
n3['是否使用 SQL 存儲']
n4{if self.storage_mode == 'memory'}
n5[return False]
n6{if self.storage_mode == 'sql'}
n7[return True]
n8[return self.db_url is not None]
n9[]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;是否使用 SQL 存儲&#39;]
n4{if self.storage_mode == &#39;memory&#39;}
n5[return False]
n6{if self.storage_mode == &#39;sql&#39;}
n7[return True]
n8[return self.db_url is not None]
n9[]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n2
1063. integration aiva integration settings Function validate
flowchart TB
n1([開始])
n2([結束])
n3['驗證配置有效性']
n4{if self.use_sql_storage and (n...}
n5[raise ValueError('SQL storage mode requir...]
n6[]
n7{if self.rate_limit_rps <= 0}
n8[raise ValueError('Rate limit RPS must be ...]
n9[]
n10{if self.rate_limit_burst <= 0}
n11[raise ValueError('Rate limit burst must b...]
n12[]
n13{if self.db_pool_size <= 0}
n14[raise ValueError('Database pool size must...]
n15[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證配置有效性&#39;]
n4{if self.use_sql_storage and (n...}
n5[raise ValueError(&#39;SQL storage mode requir...]
n6[]
n7{if self.rate_limit_rps &lt;= 0}
n8[raise ValueError(&#39;Rate limit RPS must be ...]
n9[]
n10{if self.rate_limit_burst &lt;= 0}
n11[raise ValueError(&#39;Rate limit burst must b...]
n12[]
n13{if self.db_pool_size &lt;= 0}
n14[raise ValueError(&#39;Database pool size must...]
n15[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n2
1064. integration aiva integration threat intel threat intel intel aggregator Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化威脅情報聚合器\n\n Args:\n ...]
n4[self.vt_api_key = vt_api_key or os.get...]
n5[self.abuseipdb_api_key = abuseipdb_api_key or...]
n6[self.shodan_api_key = shodan_api_key or os...]
n7[self.cache_ttl = cache_ttl]
n8[self.max_concurrent = max_concurrent]
n9[self.semaphore = asyncio.Semaphore(ma...]
n10[self._cache: dict[str, dict[str, Any]] = ...]
n11[self._cache_timestamps: dict[str, datetime] = ...]
n12[self.http_client: httpx.AsyncClient | None = None]
n13[logger.info('intel_aggregator_initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化威脅情報聚合器\n\n Args:\n ...]
n4[self.vt_api_key = vt_api_key or os.get...]
n5[self.abuseipdb_api_key = abuseipdb_api_key or...]
n6[self.shodan_api_key = shodan_api_key or os...]
n7[self.cache_ttl = cache_ttl]
n8[self.max_concurrent = max_concurrent]
n9[self.semaphore = asyncio.Semaphore(ma...]
n10[self._cache: dict[str, dict[str, Any]] = ...]
n11[self._cache_timestamps: dict[str, datetime] = ...]
n12[self.http_client: httpx.AsyncClient | None = None]
n13[logger.info(&#39;intel_aggregator_initialized...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1065. integration aiva integration threat intel threat intel intel aggregator Function calculate abuseipdb threat level
flowchart TB
n1([開始])
n2([結束])
n3['根據 AbuseIPDB 信心分數計算威脅等級']
n4{if confidence_score >= 90}
n5[return ThreatLevel.CRITICAL]
n6{if confidence_score >= 75}
n7[return ThreatLevel.HIGH]
n8{if confidence_score >= 50}
n9[return ThreatLevel.MEDIUM]
n10{if confidence_score >= 25}
n11[return ThreatLevel.LOW]
n12[return ThreatLevel.INFO]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;根據 AbuseIPDB 信心分數計算威脅等級&#39;]
n4{if confidence_score &gt;= 90}
n5[return ThreatLevel.CRITICAL]
n6{if confidence_score &gt;= 75}
n7[return ThreatLevel.HIGH]
n8{if confidence_score &gt;= 50}
n9[return ThreatLevel.MEDIUM]
n10{if confidence_score &gt;= 25}
n11[return ThreatLevel.LOW]
n12[return ThreatLevel.INFO]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1066. integration aiva integration threat intel threat intel intel aggregator Function calculate vt threat level
flowchart TB
n1([開始])
n2([結束])
n3['根據 VirusTotal 統計計算威脅等級']
n4[malicious = stats.get('malicious...]
n5[suspicious = stats.get('suspiciou...]
n6[total = sum(stats.values())]
n7{if total == 0}
n8[return ThreatLevel.UNKNOWN]
n9[]
n10[malicious_ratio = (malicious + suspici...]
n11{if malicious_ratio >= 0.5}
n12[return ThreatLevel.CRITICAL]
n13{if malicious_ratio >= 0.3}
n14[return ThreatLevel.HIGH]
n15{if malicious_ratio >= 0.1}
n16[return ThreatLevel.MEDIUM]
n17{if malicious_ratio > 0}
n18[return ThreatLevel.LOW]
n19[return ThreatLevel.INFO]
n20[]
n21[]
n22[]
n23[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n23
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n22
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n21
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;根據 VirusTotal 統計計算威脅等級&#39;]
n4[malicious = stats.get(&#39;malicious...]
n5[suspicious = stats.get(&#39;suspiciou...]
n6[total = sum(stats.values())]
n7{if total == 0}
n8[return ThreatLevel.UNKNOWN]
n9[]
n10[malicious_ratio = (malicious + suspici...]
n11{if malicious_ratio &gt;= 0.5}
n12[return ThreatLevel.CRITICAL]
n13{if malicious_ratio &gt;= 0.3}
n14[return ThreatLevel.HIGH]
n15{if malicious_ratio &gt;= 0.1}
n16[return ThreatLevel.MEDIUM]
n17{if malicious_ratio &gt; 0}
n18[return ThreatLevel.LOW]
n19[return ThreatLevel.INFO]
n20[]
n21[]
n22[]
n23[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n23
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n22
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n21
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n20
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
1067. integration aiva integration threat intel threat intel intel aggregator Function generate cache key
flowchart TB
n1([開始])
n2([結束])
n3['生成快取鍵']
n4[return hashlib.sha256(f'{source}...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;生成快取鍵&#39;]
n4[return hashlib.sha256(f&#39;{source}...]
n1 --> n3
n3 --> n4
n4 --> n2
1068. integration aiva integration threat intel threat intel intel aggregator Function get available sources
flowchart TB
n1([開始])
n2([結束])
n3['獲取可用的情報源列表']
n4[sources = []]
n5{if self.vt_api_key}
n6[sources.append(IntelSource.VIRUSTOTAL)]
n7[]
n8{if self.abuseipdb_api_key}
n9[sources.append(IntelSource.ABUSEIPDB)]
n10[]
n11{if self.shodan_api_key}
n12[sources.append(IntelSource.SHODAN)]
n13[]
n14[return sources]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取可用的情報源列表&#39;]
n4[sources = []]
n5{if self.vt_api_key}
n6[sources.append(IntelSource.VIRUSTOTAL)]
n7[]
n8{if self.abuseipdb_api_key}
n9[sources.append(IntelSource.ABUSEIPDB)]
n10[]
n11{if self.shodan_api_key}
n12[sources.append(IntelSource.SHODAN)]
n13[]
n14[return sources]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n2
1069. integration aiva integration threat intel threat intel intel aggregator Function get from cache
flowchart TB
n1([開始])
n2([結束])
n3['從快取獲取數據']
n4{if cache_key not in self._cache}
n5[return None]
n6[]
n7[timestamp = self._cache_timestam...]
n8{if timestamp and datetime.now(...}
n9[del self._cache[cache_key]]
n10[del self._cache_timestamps[cache_key]]
n11[return None]
n12[]
n13[return self._cache.get(cache_key)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從快取獲取數據&#39;]
n4{if cache_key not in self._cache}
n5[return None]
n6[]
n7[timestamp = self._cache_timestam...]
n8{if timestamp and datetime.now(...}
n9[del self._cache[cache_key]]
n10[del self._cache_timestamps[cache_key]]
n11[return None]
n12[]
n13[return self._cache.get(cache_key)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1070. integration aiva integration threat intel threat intel intel aggregator Function set to cache
flowchart TB
n1([開始])
n2([結束])
n3['設置快取數據']
n4[self._cache[cache_key] = data]
n5[self._cache_timestamps[cache_key] = datetime.now&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置快取數據&#39;]
n4[self._cache[cache_key] = data]
n5[self._cache_timestamps[cache_key] = datetime.now&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1071. integration aiva integration threat intel threat intel intel aggregator Function clear cache
flowchart TB
n1([開始])
n2([結束])
n3['清除所有快取']
n4[self._cache.clear()]
n5[self._cache_timestamps.clear()]
n6[logger.info('cache_cleared')]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清除所有快取&#39;]
n4[self._cache.clear()]
n5[self._cache_timestamps.clear()]
n6[logger.info(&#39;cache_cleared&#39;)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1072. integration aiva integration threat intel threat intel ioc enricher Function del
flowchart TB
n1([開始])
n2([結束])
n3['清理資源']
n4{if self.geoip_reader}
n5[self.geoip_reader.close()]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清理資源&#39;]
n4{if self.geoip_reader}
n5[self.geoip_reader.close()]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
1073. integration aiva integration threat intel threat intel ioc enricher Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化 IOC 豐富化器\n\n Args:\n ...]
n4[self.geoip_db_path = geoip_db_path]
n5[self.dns_timeout = dns_timeout]
n6[self.whois_timeout = whois_timeout]
n7[self.geoip_reader = None]
n8{if geoip_db_path}
n9[try]
n10[self.geoip_reader = geoip2.database.Read...]
n11[logger.info('geoip_database_loaded&...]
n12[]
n13[except Exception]
n14[logger.warning('geoip_database_load_faile...]
n15[]
n16[logger.info('ioc_enricher_initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n15
n9 --> n10
n9 --> n13
n10 --> n11
n11 --> n12
n12 --> n15
n13 --> n14
n14 --> n12
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化 IOC 豐富化器\n\n Args:\n ...]
n4[self.geoip_db_path = geoip_db_path]
n5[self.dns_timeout = dns_timeout]
n6[self.whois_timeout = whois_timeout]
n7[self.geoip_reader = None]
n8{if geoip_db_path}
n9[try]
n10[self.geoip_reader = geoip2.database.Read...]
n11[logger.info(&#39;geoip_database_loaded&&#...]
n12[]
n13[except Exception]
n14[logger.warning(&#39;geoip_database_load_faile...]
n15[]
n16[logger.info(&#39;ioc_enricher_initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n15
n9 --> n10
n9 --> n13
n10 --> n11
n11 --> n12
n12 --> n15
n13 --> n14
n14 --> n12
n15 --> n16
n16 --> n2
1074. integration aiva integration threat intel threat intel ioc enricher Function analyze tld
flowchart TB
n1([開始])
n2([結束])
n3['分析 TLD']
n4[ext = tldextract.extract(d...]
n5[return {'subdomain': ext.sub...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析 TLD&#39;]
n4[ext = tldextract.extract(d...]
n5[return {&#39;subdomain&#39;: ext.sub...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1075. integration aiva integration threat intel threat intel ioc enricher Function detect hash type
flowchart TB
n1([開始])
n2([結束])
n3['偵測雜湊類型']
n4[hash_types = {32: 'MD5', 40:...]
n5[return hash_types.get(len(hash_value)...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;偵測雜湊類型&#39;]
n4[hash_types = {32: &#39;MD5&#39;, 40:...]
n5[return hash_types.get(len(hash_value)...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1076. integration aiva integration threat intel threat intel ioc enricher Function query geoip
flowchart TB
n1([開始])
n2([結束])
n3['查詢 GeoIP 資訊']
n4{if not self.geoip_reader}
n5[return {'error': ...]
n6[]
n7[try]
n8[response = self.geoip_reader.ci...]
n9[return {'country': {&am...]
n10[]
n11[except Exception]
n12[return {'error': f&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n11
n8 --> n9
n9 --> n10
n10 --> n2
n11 --> n12
n12 --> n10
flowchart TB
n1([開始])
n2([結束])
n3[&#39;查詢 GeoIP 資訊&#39;]
n4{if not self.geoip_reader}
n5[return {&#39;error&#39;: &#3...]
n6[]
n7[try]
n8[response = self.geoip_reader.ci...]
n9[return {&#39;country&#39;: {&am...]
n10[]
n11[except Exception]
n12[return {&#39;error&#39;: f&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n11
n8 --> n9
n9 --> n10
n10 --> n2
n11 --> n12
n12 --> n10
1077. integration aiva integration threat intel threat intel ioc enricher Function rdns lookup
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4[(hostname, aliaslist, ipaddrlist) = socket.gethos...]
n5[return {'hostname': hostname...]
n6[]
n7[except socket.herror]
n8[return {'error': str(e...]
n1 --> n3
n3 --> n4
n3 --> n7
n4 --> n5
n5 --> n6
n6 --> n2
n7 --> n8
n8 --> n6
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4[(hostname, aliaslist, ipaddrlist) = socket.gethos...]
n5[return {&#39;hostname&#39;: hostname...]
n6[]
n7[except socket.herror]
n8[return {&#39;error&#39;: str(e&#...]
n1 --> n3
n3 --> n4
n3 --> n7
n4 --> n5
n5 --> n6
n6 --> n2
n7 --> n8
n8 --> n6
1078. integration aiva integration threat intel threat intel ioc enricher Function resolve
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4{if record_type == 'A'}
n5[return socket.getaddrinfo(domain, Non...]
n6{if record_type == 'AAAA'}
n7[return socket.getaddrinfo(domain, Non...]
n8[return []]
n9[]
n10[]
n11[]
n12[except socket.gaierror]
n13[return []]
n1 --> n3
n3 --> n4
n3 --> n12
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
n12 --> n13
n13 --> n11
flowchart TB
n1([開始])
n2([結束])
n3[try]
n4{if record_type == &#39;A&#39;}
n5[return socket.getaddrinfo(domain, Non...]
n6{if record_type == &#39;AAAA&#39;}
n7[return socket.getaddrinfo(domain, Non...]
n8[return []]
n9[]
n10[]
n11[]
n12[except socket.gaierror]
n13[return []]
n1 --> n3
n3 --> n4
n3 --> n12
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n10
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
n12 --> n13
n13 --> n11
1079. integration aiva integration threat intel threat intel ioc enricher Function whois query
flowchart TB
n1([開始])
n2([結束])
n3[obj = IPWhois(ip_address, ...]
n4[result = obj.lookup_rdap(dept...]
n5[return {'asn': result.get...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[obj = IPWhois(ip_address, ...]
n4[result = obj.lookup_rdap(dept...]
n5[return {&#39;asn&#39;: result.get...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1080. integration aiva integration threat intel threat intel ioc enricher Function whois
flowchart TB
n1([開始])
n2([結束])
n3[result = whois_query(domain)]
n4{if result}
n5[return {'registrar': getattr...]
n6[]
n7[return {'error': ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[result = whois_query(domain)]
n4{if result}
n5[return {&#39;registrar&#39;: getattr...]
n6[]
n7[return {&#39;error&#39;: &#3...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1081. integration aiva integration threat intel threat intel mitre mapper Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化 MITRE 映射器\n\n Args:\n ...]
n4[self.matrix = matrix]
n5[self.cache_dir = cache_dir]
n6[self.auto_update = auto_update]
n7[os.makedirs(cache_dir, exist_ok=True)]
n8[self.attack_data: MitreAttackData | None = None]
n9[self._load_attack_data()]
n10[logger.info('mitre_mapper_initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化 MITRE 映射器\n\n Args:\n ...]
n4[self.matrix = matrix]
n5[self.cache_dir = cache_dir]
n6[self.auto_update = auto_update]
n7[os.makedirs(cache_dir, exist_ok=True)]
n8[self.attack_data: MitreAttackData | None = None]
n9[self._load_attack_data()]
n10[logger.info(&#39;mitre_mapper_initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1082. integration aiva integration threat intel threat intel mitre mapper Function extract tactics
flowchart TB
n1([開始])
n2([結束])
n3['從技術中提取戰術']
n4[kill_chain_phases = technique.get('kill_...]
n5[tactics = []]
n6{for phase in kill_chain_phases}
n7{if phase.get('kill_chain_name'...}
n8[tactic_name = phase.get('phase_nam...]
n9[tactics.append(tactic_name)]
n10[]
n11[]
n12[return tactics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從技術中提取戰術&#39;]
n4[kill_chain_phases = technique.get(&#39;kill_...]
n5[tactics = []]
n6{for phase in kill_chain_phases}
n7{if phase.get(&#39;kill_chain_name&#39...}
n8[tactic_name = phase.get(&#39;phase_nam...]
n9[tactics.append(tactic_name)]
n10[]
n11[]
n12[return tactics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n2
1083. integration aiva integration threat intel threat intel mitre mapper Function load attack data
flowchart TB
n1([開始])
n2([結束])
n3['載入 MITRE ATT&CK 數據']
n4[try]
n5[self.attack_data = MitreAttackData(self...]
n6[logger.info('mitre_attack_data_loaded&...]
n7[]
n8[except Exception]
n9[logger.error('mitre_attack_data_load_fail...]
n10[self.attack_data = None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n7
flowchart TB
n1([開始])
n2([結束])
n3[&#39;載入 MITRE ATT&CK 數據&#39;]
n4[try]
n5[self.attack_data = MitreAttackData(self...]
n6[logger.info(&#39;mitre_attack_data_loaded&...]
n7[]
n8[except Exception]
n9[logger.error(&#39;mitre_attack_data_load_fail...]
n10[self.attack_data = None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n8
n5 --> n6
n6 --> n7
n7 --> n2
n8 --> n9
n9 --> n10
n10 --> n7
1084. integration aiva integration threat intel threat intel mitre mapper Function generate attack path
flowchart TB
n1([開始])
n2([結束])
n3['\n 生成攻擊路徑\n\n Args:\n ...]
n4[path = {'techniques': [&...]
n5{for tech_id in techniques}
n6[technique = self.get_technique_b...]
n7{if technique}
n8[path['techniques'].append...]
n9[path['tactics_coverage']....]
n10[]
n11[]
n12[path['tactics_coverage'] ...]
n13[path['completeness_score']...]
n14[logger.info('attack_path_generated&...]
n15[return path]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n5
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 生成攻擊路徑\n\n Args:\n ...]
n4[path = {&#39;techniques&#39;: [&...]
n5{for tech_id in techniques}
n6[technique = self.get_technique_b...]
n7{if technique}
n8[path[&#39;techniques&#39;].append...]
n9[path[&#39;tactics_coverage&#39;]....]
n10[]
n11[]
n12[path[&#39;tactics_coverage&#39;] ...]
n13[path[&#39;completeness_score&#39;]...]
n14[logger.info(&#39;attack_path_generated&&#...]
n15[return path]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n5
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
1085. integration aiva integration threat intel threat intel mitre mapper Function get mitigations for technique
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取技術的緩解措施\n\n Args:\n ...]
n4{if not self.attack_data}
n5[return []]
n6[]
n7[try]
n8[techniques = self.attack_data.get...]
n9[technique_obj = None]
n10{for tech in techniques}
n11[external_refs = tech.get('external_r...]
n12{for ref in external_refs}
n13{if ref.get('source_name')...}
n14[technique_obj = tech]
n15[break]
n16[]
n17[]
n18{if technique_obj}
n19[break]
n20[]
n21[]
n22{if not technique_obj}
n23[return []]
n24[]
n25[tech_id_raw = technique_obj.get('i...]
n26{if not tech_id_raw or not isin...}
n27[return []]
n28[]
n29[tech_id: str = tech_id_raw]
n30[mitigations = self.attack_data.get...]
n31[results = []]
n32{for mitigation in mitigations}
n33[external_refs = mitigation.get('exte...]
n34[mitigation_id = None]
n35{for ref in external_refs}
n36{if ref.get('source_name')...}
n37[mitigation_id = ref.get('external_id...]
n38[break]
n39[]
n40[]
n41[results.append({'id': mi...]
n42[]
n43[logger.info('mitigations_retrieved&...]
n44[return results]
n45[]
n46[except Exception]
n47[logger.error('get_mitigations_failed&...]
n48[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n46
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n21
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n17
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n12
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n10
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n42
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n40
n36 -->|Yes| n37
n36 -->|No| n39
n37 --> n38
n38 --> n39
n39 --> n35
n40 --> n41
n41 --> n32
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n2
n46 --> n47
n47 --> n48
n48 --> n45
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取技術的緩解措施\n\n Args:\n ...]
n4{if not self.attack_data}
n5[return []]
n6[]
n7[try]
n8[techniques = self.attack_data.get...]
n9[technique_obj = None]
n10{for tech in techniques}
n11[external_refs = tech.get(&#39;external_r...]
n12{for ref in external_refs}
n13{if ref.get(&#39;source_name&#39;)...}
n14[technique_obj = tech]
n15[break]
n16[]
n17[]
n18{if technique_obj}
n19[break]
n20[]
n21[]
n22{if not technique_obj}
n23[return []]
n24[]
n25[tech_id_raw = technique_obj.get(&#39;i...]
n26{if not tech_id_raw or not isin...}
n27[return []]
n28[]
n29[tech_id: str = tech_id_raw]
n30[mitigations = self.attack_data.get...]
n31[results = []]
n32{for mitigation in mitigations}
n33[external_refs = mitigation.get(&#39;exte...]
n34[mitigation_id = None]
n35{for ref in external_refs}
n36{if ref.get(&#39;source_name&#39;)...}
n37[mitigation_id = ref.get(&#39;external_id...]
n38[break]
n39[]
n40[]
n41[results.append({&#39;id&#39;: mi...]
n42[]
n43[logger.info(&#39;mitigations_retrieved&&#...]
n44[return results]
n45[]
n46[except Exception]
n47[logger.error(&#39;get_mitigations_failed&...]
n48[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n46
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n21
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n17
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n12
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n20
n19 --> n20
n20 --> n10
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n42
n33 --> n34
n34 --> n35
n35 -->|Yes| n36
n35 -->|No| n40
n36 -->|Yes| n37
n36 -->|No| n39
n37 --> n38
n38 --> n39
n39 --> n35
n40 --> n41
n41 --> n32
n42 --> n43
n43 --> n44
n44 --> n45
n45 --> n2
n46 --> n47
n47 --> n48
n48 --> n45
1086. integration aiva integration threat intel threat intel mitre mapper Function get tactics
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取所有戰術\n\n Returns:\n ...]
n4{if not self.attack_data}
n5[return []]
n6[]
n7[try]
n8[tactics = self.attack_data.get...]
n9[results = []]
n10{for tactic in tactics}
n11[external_refs = tactic.get('external...]
n12[tactic_id = None]
n13[tactic_url = None]
n14{for ref in external_refs}
n15{if ref.get('source_name')...}
n16[tactic_id = ref.get('external_id...]
n17[tactic_url = ref.get('url')]
n18[break]
n19[]
n20[]
n21[results.append({'id': ta...]
n22[]
n23[logger.info('tactics_retrieved...]
n24[return results]
n25[]
n26[except Exception]
n27[logger.error('get_tactics_failed&#...]
n28[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n26
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n22
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 -->|Yes| n16
n15 -->|No| n19
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n14
n20 --> n21
n21 --> n10
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
n26 --> n27
n27 --> n28
n28 --> n25
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取所有戰術\n\n Returns:\n ...]
n4{if not self.attack_data}
n5[return []]
n6[]
n7[try]
n8[tactics = self.attack_data.get...]
n9[results = []]
n10{for tactic in tactics}
n11[external_refs = tactic.get(&#39;external...]
n12[tactic_id = None]
n13[tactic_url = None]
n14{for ref in external_refs}
n15{if ref.get(&#39;source_name&#39;)...}
n16[tactic_id = ref.get(&#39;external_id...]
n17[tactic_url = ref.get(&#39;url&#39;)]
n18[break]
n19[]
n20[]
n21[results.append({&#39;id&#39;: ta...]
n22[]
n23[logger.info(&#39;tactics_retrieved&#3...]
n24[return results]
n25[]
n26[except Exception]
n27[logger.error(&#39;get_tactics_failed&#...]
n28[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n26
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n22
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n20
n15 -->|Yes| n16
n15 -->|No| n19
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n14
n20 --> n21
n21 --> n10
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
n26 --> n27
n27 --> n28
n28 --> n25
1087. integration aiva integration threat intel threat intel mitre mapper Function get technique by id
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據技術 ID 獲取技術資訊\n\n Args:\n ...]
n4{if not self.attack_data}
n5[return None]
n6[]
n7[try]
n8[techniques = self.attack_data.get...]
n9{for technique in techniques}
n10[external_refs = technique.get('exter...]
n11{for ref in external_refs}
n12{if ref.get('source_name')...}
n13[return {'id': technique_id, ...]
n14[]
n15[]
n16[]
n17[return None]
n18[]
n19[except Exception]
n20[logger.error('get_technique_failed&...]
n21[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n19
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n11
n15 --> n9
n16 --> n17
n17 --> n18
n18 --> n2
n19 --> n20
n20 --> n21
n21 --> n18
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據技術 ID 獲取技術資訊\n\n Args:\n ...]
n4{if not self.attack_data}
n5[return None]
n6[]
n7[try]
n8[techniques = self.attack_data.get...]
n9{for technique in techniques}
n10[external_refs = technique.get(&#39;exter...]
n11{for ref in external_refs}
n12{if ref.get(&#39;source_name&#39;)...}
n13[return {&#39;id&#39;: technique_id, ...]
n14[]
n15[]
n16[]
n17[return None]
n18[]
n19[except Exception]
n20[logger.error(&#39;get_technique_failed&&#...]
n21[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n19
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n16
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n15
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n11
n15 --> n9
n16 --> n17
n17 --> n18
n18 --> n2
n19 --> n20
n20 --> n21
n21 --> n18
1088. integration aiva integration threat intel threat intel mitre mapper Function main
flowchart TB
n1([開始])
n2([結束])
n3['測試範例']
n4[mapper = MitreMapper()]
n5[print('=== Technique Information ===&...]
n6[technique = mapper.get_technique...]
n7[print(json.dumps(technique, indent=2, ensure_asci...]
n8[print('\n=== Search Techniques ===&...]
n9[results = mapper.search_techni...]
n10{for result in results}
n11[print(f"- {result['id&a...]
n12[]
n13[print('\n=== Tactics ===')]
n14[tactics = mapper.get_tactics()]
n15{for tactic in tactics[:5]}
n16[print(f"- {tactic['id&a...]
n17[]
n18[print('\n=== Mitigations for T1055 ===&am...]
n19[mitigations = mapper.get_mitigatio...]
n20{for mitigation in mitigations}
n21[print(f"- {mitigation['...]
n22[]
n23[print('\n=== Vulnerability Mapping ===&am...]
n24[vuln_desc = 'SQL injection vulne...]
n25[techniques = mapper.map_vulnerabi...]
n26{for tech in techniques}
n27[print(f"- {tech['id&...]
n28[]
n29[print('\n=== Attack Path ==='...]
n30[path = mapper.generate_atta...]
n31[print(f"Techniques: {len(path[&...]
n32[print(f"Tactics Coverage: {path[&am...]
n33[print(f"Completeness: {path[&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n15
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n20
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n26
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;測試範例&#39;]
n4[mapper = MitreMapper()]
n5[print(&#39;=== Technique Information ===&...]
n6[technique = mapper.get_technique...]
n7[print(json.dumps(technique, indent=2, ensure_asci...]
n8[print(&#39;\n=== Search Techniques ===&&#...]
n9[results = mapper.search_techni...]
n10{for result in results}
n11[print(f&quot;- {result[&#39;id&a...]
n12[]
n13[print(&#39;\n=== Tactics ===&#39;)]
n14[tactics = mapper.get_tactics()]
n15{for tactic in tactics[:5]}
n16[print(f&quot;- {tactic[&#39;id&a...]
n17[]
n18[print(&#39;\n=== Mitigations for T1055 ===&am...]
n19[mitigations = mapper.get_mitigatio...]
n20{for mitigation in mitigations}
n21[print(f&quot;- {mitigation[&#39;...]
n22[]
n23[print(&#39;\n=== Vulnerability Mapping ===&am...]
n24[vuln_desc = &#39;SQL injection vulne...]
n25[techniques = mapper.map_vulnerabi...]
n26{for tech in techniques}
n27[print(f&quot;- {tech[&#39;id&...]
n28[]
n29[print(&#39;\n=== Attack Path ===&#39;...]
n30[path = mapper.generate_atta...]
n31[print(f&quot;Techniques: {len(path[&...]
n32[print(f&quot;Tactics Coverage: {path[&am...]
n33[print(f&quot;Completeness: {path[&&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n10
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n15
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n20
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n26
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
1089. integration aiva integration threat intel threat intel mitre mapper Function map vulnerability to techniques
flowchart TB
n1([開始])
n2([結束])
n3['\n 將漏洞映射到 ATT&CK 技術\n\n Ar...]
n4[keyword_mapping = {'injection...]
n5[cwe_mapping = {'CWE-79': ...]
n6[matched_technique_ids = set()]
n7[description_lower = vulnerability_descri...]
n8{for (keyword, technique_ids) in keyword_mapping.i...}
n9{if keyword in description_lower}
n10[matched_technique_ids.update(technique_ids)]
n11[]
n12[]
n13{if cwe_id and cwe_id in cwe_ma...}
n14[matched_technique_ids.update(cwe_mapping[cwe_id...]
n15[]
n16[techniques = []]
n17{for tech_id in matched_technique...}
n18[technique = self.get_technique_b...]
n19{if technique}
n20[techniques.append(technique)]
n21[]
n22[]
n23[logger.info('vulnerability_mapped&...]
n24[return techniques]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n17
n22 --> n23
n23 --> n24
n24 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將漏洞映射到 ATT&CK 技術\n\n Ar...]
n4[keyword_mapping = {&#39;injection&#3...]
n5[cwe_mapping = {&#39;CWE-79&#39;: 	...]
n6[matched_technique_ids = set()]
n7[description_lower = vulnerability_descri...]
n8{for (keyword, technique_ids) in keyword_mapping.i...}
n9{if keyword in description_lower}
n10[matched_technique_ids.update(technique_ids)]
n11[]
n12[]
n13{if cwe_id and cwe_id in cwe_ma...}
n14[matched_technique_ids.update(cwe_mapping[cwe_id&#...]
n15[]
n16[techniques = []]
n17{for tech_id in matched_technique...}
n18[technique = self.get_technique_b...]
n19{if technique}
n20[techniques.append(technique)]
n21[]
n22[]
n23[logger.info(&#39;vulnerability_mapped&...]
n24[return techniques]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n12
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n8
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n17
n22 --> n23
n23 --> n24
n24 --> n2
1090. integration aiva integration threat intel threat intel mitre mapper Function search techniques by keyword
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據關鍵字搜尋技術\n\n Args:\n ...]
n4{if not self.attack_data}
n5[return []]
n6[]
n7[try]
n8[techniques = self.attack_data.get...]
n9[results = []]
n10[keyword_lower = keyword.lower()]
n11{for technique in techniques}
n12[name = technique.get('name'...]
n13[description = technique.get('descr...]
n14{if keyword_lower in name or ke...}
n15[tech_id = None]
n16[external_refs = technique.get('exter...]
n17{for ref in external_refs}
n18{if ref.get('source_name')...}
n19[tech_id = ref.get('external_id...]
n20[break]
n21[]
n22[]
n23{if tech_id}
n24[results.append({'id': te...]
n25[]
n26{if len(results) >= limit}
n27[break]
n28[]
n29[]
n30[]
n31[logger.info('techniques_searched&#...]
n32[return results]
n33[]
n34[except Exception]
n35[logger.error('search_techniques_failed&am...]
n36[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n34
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n30
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n29
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 -->|Yes| n19
n18 -->|No| n21
n19 --> n20
n20 --> n21
n21 --> n17
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n11
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
n34 --> n35
n35 --> n36
n36 --> n33
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據關鍵字搜尋技術\n\n Args:\n ...]
n4{if not self.attack_data}
n5[return []]
n6[]
n7[try]
n8[techniques = self.attack_data.get...]
n9[results = []]
n10[keyword_lower = keyword.lower()]
n11{for technique in techniques}
n12[name = technique.get(&#39;name&#39;...]
n13[description = technique.get(&#39;descr...]
n14{if keyword_lower in name or ke...}
n15[tech_id = None]
n16[external_refs = technique.get(&#39;exter...]
n17{for ref in external_refs}
n18{if ref.get(&#39;source_name&#39;)...}
n19[tech_id = ref.get(&#39;external_id...]
n20[break]
n21[]
n22[]
n23{if tech_id}
n24[results.append({&#39;id&#39;: te...]
n25[]
n26{if len(results) &gt;= limit}
n27[break]
n28[]
n29[]
n30[]
n31[logger.info(&#39;techniques_searched&#...]
n32[return results]
n33[]
n34[except Exception]
n35[logger.error(&#39;search_techniques_failed&am...]
n36[return []]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n7 --> n34
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n30
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n29
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n22
n18 -->|Yes| n19
n18 -->|No| n21
n19 --> n20
n20 --> n21
n21 --> n17
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n28
n27 --> n28
n28 --> n29
n29 --> n11
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n2
n34 --> n35
n35 --> n36
n36 --> n33
1091. integration alembic env Function do run migrations
flowchart TB
n1([開始])
n2([結束])
n3['執行遷移的核心邏輯']
n4[context.configure(connection=connection, target_me...]
n5[with context.b...]
n6[context.run_migrations()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;執行遷移的核心邏輯&#39;]
n4[context.configure(connection=connection, target_me...]
n5[with context.b...]
n6[context.run_migrations()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1092. integration alembic env Function get database url
flowchart TB
n1([開始])
n2([結束])
n3['從環境變數獲取資料庫 URL']
n4[url = os.getenv('AIVA_DATA...]
n5{if not url}
n6[raise ValueError('AIVA_DATABASE_URL envir...]
n7[]
n8[return url]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;從環境變數獲取資料庫 URL&#39;]
n4[url = os.getenv(&#39;AIVA_DATA...]
n5{if not url}
n6[raise ValueError(&#39;AIVA_DATABASE_URL envir...]
n7[]
n8[return url]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1093. integration alembic env Function run migrations offline
flowchart TB
n1([開始])
n2([結束])
n3['離線模式運行遷移']
n4[url = get_database_url()]
n5[context.configure(url=url, target_metadata=target_...]
n6[with context.b...]
n7[context.run_migrations()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;離線模式運行遷移&#39;]
n4[url = get_database_url()]
n5[context.configure(url=url, target_metadata=target_...]
n6[with context.b...]
n7[context.run_migrations()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1094. integration alembic env Function run migrations online
flowchart TB
n1([開始])
n2([結束])
n3['在線模式運行遷移']
n4[asyncio.run(run_async_migrations())]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;在線模式運行遷移&#39;]
n4[asyncio.run(run_async_migrations())]
n1 --> n3
n3 --> n4
n4 --> n2
1095. integration alembic versions 001 initial schema Function downgrade
flowchart TB
n1([開始])
n2([結束])
n3['撤銷遷移']
n4[op.drop_table('task_executions...]
n5[op.drop_table('reports')]
n6[op.drop_table('findings')]
n7[op.drop_table('scans')]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;撤銷遷移&#39;]
n4[op.drop_table(&#39;task_executions&#3...]
n5[op.drop_table(&#39;reports&#39;)]
n6[op.drop_table(&#39;findings&#39;)]
n7[op.drop_table(&#39;scans&#39;)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1096. integration alembic versions 001 initial schema Function upgrade
flowchart TB
n1([開始])
n2([結束])
n3['創建初始資料庫表結構']
n4[op.create_table('scans', sa.C...]
n5[op.create_table('findings', s...]
n6[op.create_table('reports', sa...]
n7[op.create_table('task_executions&#...]
n8[op.create_index('idx_scans_status&...]
n9[op.create_index('idx_scans_created_at&...]
n10[op.create_index('idx_findings_finding_id&...]
n11[op.create_index('idx_findings_scan_id&...]
n12[op.create_index('idx_findings_task_id&...]
n13[op.create_index('idx_findings_severity&am...]
n14[op.create_index('idx_findings_status&...]
n15[op.create_index('idx_findings_created_at&...]
n16[op.create_index('idx_reports_report_id&am...]
n17[op.create_index('idx_reports_scan_id&...]
n18[op.create_index('idx_reports_status&&...]
n19[op.create_index('idx_reports_format&&...]
n20[op.create_index('idx_reports_created_at&a...]
n21[op.create_index('idx_task_executions_task...]
n22[op.create_index('idx_task_executions_scan...]
n23[op.create_index('idx_task_executions_stat...]
n24[op.create_index('idx_task_executions_task...]
n25[op.create_index('idx_task_executions_star...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建初始資料庫表結構&#39;]
n4[op.create_table(&#39;scans&#39;, sa.C...]
n5[op.create_table(&#39;findings&#39;, s...]
n6[op.create_table(&#39;reports&#39;, sa...]
n7[op.create_table(&#39;task_executions&#...]
n8[op.create_index(&#39;idx_scans_status&...]
n9[op.create_index(&#39;idx_scans_created_at&...]
n10[op.create_index(&#39;idx_findings_finding_id&...]
n11[op.create_index(&#39;idx_findings_scan_id&...]
n12[op.create_index(&#39;idx_findings_task_id&...]
n13[op.create_index(&#39;idx_findings_severity&am...]
n14[op.create_index(&#39;idx_findings_status&...]
n15[op.create_index(&#39;idx_findings_created_at&...]
n16[op.create_index(&#39;idx_reports_report_id&am...]
n17[op.create_index(&#39;idx_reports_scan_id&...]
n18[op.create_index(&#39;idx_reports_status&&...]
n19[op.create_index(&#39;idx_reports_format&&...]
n20[op.create_index(&#39;idx_reports_created_at&a...]
n21[op.create_index(&#39;idx_task_executions_task...]
n22[op.create_index(&#39;idx_task_executions_scan...]
n23[op.create_index(&#39;idx_task_executions_stat...]
n24[op.create_index(&#39;idx_task_executions_task...]
n25[op.create_index(&#39;idx_task_executions_star...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
1097. message broker Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 RPC 客戶端\n\n Args:\n ch...]
n4[self.channel = channel]
n5[self.exchange = exchange]
n6[self.timeout = timeout]
n7[self.futures: dict[str, asyncio.Future] = {&...]
n8[self.callback_queue: AbstractQueue | None = None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 RPC 客戶端\n\n Args:\n ch...]
n4[self.channel = channel]
n5[self.exchange = exchange]
n6[self.timeout = timeout]
n7[self.futures: dict[str, asyncio.Future] = {&...]
n8[self.callback_queue: AbstractQueue | None = None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1098. result collector Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化結果收集器\n\n Args:\n broke...]
n4[self.broker = broker]
n5[self.storage = storage_backend]
n6[self.result_handlers: dict[str, list[Callable]...]
n7[self.pending_results: dict[str, dict[str, Any]...]
n8[logger.info('ResultCollector initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化結果收集器\n\n Args:\n broke...]
n4[self.broker = broker]
n5[self.storage = storage_backend]
n6[self.result_handlers: dict[str, list[Callable]...]
n7[self.pending_results: dict[str, dict[str, Any]...]
n8[logger.info(&#39;ResultCollector initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1099. result collector Function set pending result
flowchart TB
n1([開始])
n2([結束])
n3['設置等待中的結果\n\n Args:\n resul...]
n4[self.pending_results[result_id] = {&#...]
n5[logger.debug(f'Set pending result for ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置等待中的結果\n\n Args:\n resul...]
n4[self.pending_results[result_id] = {&#...]
n5[logger.debug(f&#39;Set pending result for ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1100. result collector Function register handler
flowchart TB
n1([開始])
n2([結束])
n3['註冊結果處理器\n\n Args:\n event_...]
n4{if event_type not in self.resu...}
n5[self.result_handlers[event_type] = []]
n6[]
n7[self.result_handlers[event_type].append(handl...]
n8[logger.debug(f'Registered handler for ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊結果處理器\n\n Args:\n event_...]
n4{if event_type not in self.resu...}
n5[self.result_handlers[event_type] = []]
n6[]
n7[self.result_handlers[event_type].append(handl...]
n8[logger.debug(f&#39;Registered handler for ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1101. result collector Function unregister handler
flowchart TB
n1([開始])
n2([結束])
n3['取消註冊處理器\n\n Args:\n event_...]
n4{if event_type in self.result_h...}
n5[try]
n6[self.result_handlers[event_type].remove(handl...]
n7[logger.debug(f'Unregistered handler for &...]
n8[]
n9[except ValueError]
n10[pass]
n11[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n11
n5 --> n6
n5 --> n9
n6 --> n7
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n8
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取消註冊處理器\n\n Args:\n event_...]
n4{if event_type in self.result_h...}
n5[try]
n6[self.result_handlers[event_type].remove(handl...]
n7[logger.debug(f&#39;Unregistered handler for &...]
n8[]
n9[except ValueError]
n10[pass]
n11[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n11
n5 --> n6
n5 --> n9
n6 --> n7
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n8
n11 --> n2
1102. task dispatcher Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化任務派發器\n\n Args:\n broke...]
n4[self.broker = broker]
n5[self.module_name = module_name]
n6[self.task_callbacks: dict[str, Callable] = {...]
n7[self.tool_routing_map = {'function_sqli&...]
n8[logger.info('TaskDispatcher initialized&a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化任務派發器\n\n Args:\n broke...]
n4[self.broker = broker]
n5[self.module_name = module_name]
n6[self.task_callbacks: dict[str, Callable] = {...]
n7[self.tool_routing_map = {&#39;function_sqli&...]
n8[logger.info(&#39;TaskDispatcher initialized&a...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1103. task dispatcher Function build message
flowchart TB
n1([開始])
n2([結束])
n3['構建 AIVA 消息\n\n Args:\n top...]
n4[header = MessageHeader(messag...]
n5[message = AivaMessage(header=h...]
n6[return message]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建 AIVA 消息\n\n Args:\n top...]
n4[header = MessageHeader(messag...]
n5[message = AivaMessage(header=h...]
n6[return message]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1104. task dispatcher Function build task payload
flowchart TB
n1([開始])
n2([結束])
n3['構建功能任務 Payload\n\n Args:\n ...]
n4[target = FunctionTaskTarget(u...]
n5[payload = FunctionTaskPayload(...]
n6[return payload]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建功能任務 Payload\n\n Args:\n ...]
n4[target = FunctionTaskTarget(u...]
n5[payload = FunctionTaskPayload(...]
n6[return payload]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1105. task dispatcher Function get topic for tool
flowchart TB
n1([開始])
n2([結束])
n3['根據工具類型獲取對應的 Topic\n\n Args:\n ...]
n4[topic_map = {'function_sqli'...]
n5[return topic_map.get(tool_type, Topic...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;根據工具類型獲取對應的 Topic\n\n Args:\n ...]
n4[topic_map = {&#39;function_sqli&#39;...]
n5[return topic_map.get(tool_type, Topic...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1106. task dispatcher Function register callback
flowchart TB
n1([開始])
n2([結束])
n3['註冊任務完成回調\n\n Args:\n task_...]
n4[self.task_callbacks[task_id] = callback]
n5[logger.debug(f'Registered callback for ta...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊任務完成回調\n\n Args:\n task_...]
n4[self.task_callbacks[task_id] = callback]
n5[logger.debug(f&#39;Registered callback for ta...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1107. task dispatcher Function unregister callback
flowchart TB
n1([開始])
n2([結束])
n3['取消註冊回調\n\n Args:\n task_id...]
n4{if task_id in self.task_callbacks}
n5[del self.task_callbacks[task_id]]
n6[logger.debug(f'Unregistered callback for ...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取消註冊回調\n\n Args:\n task_id...]
n4{if task_id in self.task_callbacks}
n5[del self.task_callbacks[task_id]]
n6[logger.debug(f&#39;Unregistered callback for ...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
1108. aiva func sqli init Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
1109. aiva func sqli backend db fingerprinter Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._db_patterns = {'MySQL'...]
n4[self._version_patterns = {'MySQL&...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._db_patterns = {&#39;MySQL&#39;...]
n4[self._version_patterns = {&#39;MySQL&...]
n1 --> n3
n3 --> n4
n4 --> n2
1110. aiva func sqli backend db fingerprinter Function contains sql keywords
flowchart TB
n1([開始])
n2([結束])
n3['檢測文本中的SQL關鍵字']
n4[sql_keywords = ['SELECT', &am...]
n5[found_keywords = []]
n6[text_upper = text.upper()]
n7{for keyword in sql_keywords}
n8{if keyword in text_upper}
n9[found_keywords.append(keyword)]
n10[]
n11[]
n12[return found_keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測文本中的SQL關鍵字&#39;]
n4[sql_keywords = [&#39;SELECT&#39;, &am...]
n5[found_keywords = []]
n6[text_upper = text.upper()]
n7{for keyword in sql_keywords}
n8{if keyword in text_upper}
n9[found_keywords.append(keyword)]
n10[]
n11[]
n12[return found_keywords]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 --> n2
1111. aiva func sqli backend db fingerprinter Function extract error signatures
flowchart TB
n1([開始])
n2([結束])
n3['提取錯誤簽名']
n4[error_signatures = []]
n5[error_patterns = ['syntax error&#...]
n6{for pattern in error_patterns}
n7[matches = re.findall(pattern, ...]
n8[error_signatures.extend(matches)]
n9[]
n10[return list(set(error_signatures))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n6
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取錯誤簽名&#39;]
n4[error_signatures = []]
n5[error_patterns = [&#39;syntax error&#...]
n6{for pattern in error_patterns}
n7[matches = re.findall(pattern, ...]
n8[error_signatures.extend(matches)]
n9[]
n10[return list(set(error_signatures))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n6
n9 --> n10
n10 --> n2
1112. aiva func sqli backend db fingerprinter Function extract version
flowchart TB
n1([開始])
n2([結束])
n3['提取資料庫版本資訊']
n4[version_patterns = self._version_patter...]
n5{for pattern in version_patterns}
n6[match = re.search(pattern, t...]
n7{if match}
n8[version = match.group(1)]
n9[logger.info(f'Version extracted for {...]
n10[return version]
n11[]
n12[]
n13[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取資料庫版本資訊&#39;]
n4[version_patterns = self._version_patter...]
n5{for pattern in version_patterns}
n6[match = re.search(pattern, t...]
n7{if match}
n8[version = match.group(1)]
n9[logger.info(f&#39;Version extracted for {...]
n10[return version]
n11[]
n12[]
n13[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n5
n12 --> n13
n13 --> n2
1113. aiva func sqli backend db fingerprinter Function add custom pattern
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加自定義資料庫識別模式\n\n Args:\n ...]
n4{if db_name not in self._db_pat...}
n5[self._db_patterns[db_name] = []]
n6[]
n7[self._db_patterns[db_name].append(pattern)]
n8[logger.info(f'Added custom pattern for ...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加自定義資料庫識別模式\n\n Args:\n ...]
n4{if db_name not in self._db_pat...}
n5[self._db_patterns[db_name] = []]
n6[]
n7[self._db_patterns[db_name].append(pattern)]
n8[logger.info(f&#39;Added custom pattern for &#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1114. aiva func sqli backend db fingerprinter Function add custom version pattern
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加自定義版本提取模式\n\n Args:\n ...]
n4{if db_name not in self._versio...}
n5[self._version_patterns[db_name] = []]
n6[]
n7[self._version_patterns[db_name].append(patter...]
n8[logger.info(f'Added custom version patter...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加自定義版本提取模式\n\n Args:\n ...]
n4{if db_name not in self._versio...}
n5[self._version_patterns[db_name] = []]
n6[]
n7[self._version_patterns[db_name].append(patter...]
n8[logger.info(f&#39;Added custom version patter...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1115. aiva func sqli backend db fingerprinter Function analyze response characteristics
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析回應特徵以輔助指紋識別\n\n Args:\n ...]
n4[characteristics = {'status_code&#...]
n5[return characteristics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析回應特徵以輔助指紋識別\n\n Args:\n ...]
n4[characteristics = {&#39;status_code&#...]
n5[return characteristics]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1116. aiva func sqli backend db fingerprinter Function fingerprint
flowchart TB
n1([開始])
n2([結束])
n3['\n 從HTTP回應中識別資料庫類型和版本\n\n Args...]
n4{if response is None}
n5[return None]
n6[]
n7[text_sources = [response.text or '&...]
n8[combined_text = ' '.join(text...]
n9{for (db_name, patterns) in self._db_patterns...}
n10{for pattern in patterns}
n11{if re.search(pattern, combined...}
n12[logger.info(f'Database fingerprint detect...]
n13[version = self._extract_versio...]
n14[return (db_name, version)]
n15[]
n16[]
n17[]
n18[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n17
n10 -->|Yes| n11
n10 -->|No| n16
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n9
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 從HTTP回應中識別資料庫類型和版本\n\n Args...]
n4{if response is None}
n5[return None]
n6[]
n7[text_sources = [response.text or &#39;&&#...]
n8[combined_text = &#39; &#39;.join(text...]
n9{for (db_name, patterns) in self._db_patterns...}
n10{for pattern in patterns}
n11{if re.search(pattern, combined...}
n12[logger.info(f&#39;Database fingerprint detect...]
n13[version = self._extract_versio...]
n14[return (db_name, version)]
n15[]
n16[]
n17[]
n18[return None]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n17
n10 -->|Yes| n11
n10 -->|No| n16
n11 -->|Yes| n12
n11 -->|No| n15
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n9
n17 --> n18
n18 --> n2
1117. aiva func sqli backend db fingerprinter Function get supported databases
flowchart TB
n1([開始])
n2([結束])
n3['獲取支援的資料庫類型列表']
n4[return list(self._db_patterns.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取支援的資料庫類型列表&#39;]
n4[return list(self._db_patterns.keys())]
n1 --> n3
n3 --> n4
n4 --> n2
1118. aiva func sqli backend db fingerprinter Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import re]
n5[from typing import Any]
n6[import httpx]
n7[from services.aiva_common.utils import get_logger]
n8[logger = get_logger(__name__)]
n9[class BackendDbFingerprinter(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import re]
n5[from typing import Any]
n6[import httpx]
n7[from services.aiva_common.utils import get_logger]
n8[logger = get_logger(__name__)]
n9[class BackendDbFingerprinter(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1119. aiva func sqli config Function create aggressive config
flowchart TB
n1([開始])
n2([結束])
n3['創建積極的檢測配置(用於專業測試)']
n4[return cls(engines={'error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建積極的檢測配置(用於專業測試)&#39;]
n4[return cls(engines={&#39;error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
1120. aiva func sqli config Function create safe config
flowchart TB
n1([開始])
n2([結束])
n3['創建安全的預設配置(用於生產環境)']
n4[return cls(engines={'error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;創建安全的預設配置(用於生產環境)&#39;]
n4[return cls(engines={&#39;error&#...]
n1 --> n3
n3 --> n4
n4 --> n2
1121. aiva func sqli config Function get enabled engines
flowchart TB
n1([開始])
n2([結束])
n3['取得所有啟用的引擎列表']
n4[return [engine for engine, enabled in...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取得所有啟用的引擎列表&#39;]
n4[return [engine for engine, enabled in...]
n1 --> n3
n3 --> n4
n4 --> n2
1122. aiva func sqli config Function is engine enabled
flowchart TB
n1([開始])
n2([結束])
n3['檢查指定引擎是否啟用']
n4[return self.engines.get(engine_name, ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查指定引擎是否啟用&#39;]
n4[return self.engines.get(engine_name, ...]
n1 --> n3
n3 --> n4
n4 --> n2
1123. aiva func sqli config Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['轉換為字典格式']
n4[return {'engines': self.engi...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為字典格式&#39;]
n4[return {&#39;engines&#39;: self.engi...]
n1 --> n3
n3 --> n4
n4 --> n2
1124. aiva func sqli config Function validate
flowchart TB
n1([開始])
n2([結束])
n3['配置驗證']
n4{if self.timeout_seconds <= 0}
n5[raise ValueError('timeout_seconds must be...]
n6[]
n7{if self.max_retries < 0}
n8[raise ValueError('max_retries must be non...]
n9[]
n10{if self.concurrent_limit <= 0}
n11[raise ValueError('concurrent_limit must b...]
n12[]
n13{if self.time_delay_threshold <= 0}
n14[raise ValueError('time_delay_threshold mu...]
n15[]
n16{if not 0 <= self.boolean_diff_...}
n17[raise ValueError('boolean_diff_threshold ...]
n18[]
n19{if not 0 <= self.min_confidenc...}
n20[raise ValueError('min_confidence_score mu...]
n21[]
n22{if self.max_payload_length <= 0}
n23[raise ValueError('max_payload_length must...]
n24[]
n25[valid_engines = {'error', &a...]
n26{for engine in self.engines}
n27{if engine not in valid_engines}
n28[raise ValueError(f'Unknown engine: {...]
n29[]
n30[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n26
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;配置驗證&#39;]
n4{if self.timeout_seconds &lt;= 0}
n5[raise ValueError(&#39;timeout_seconds must be...]
n6[]
n7{if self.max_retries &lt; 0}
n8[raise ValueError(&#39;max_retries must be non...]
n9[]
n10{if self.concurrent_limit &lt;= 0}
n11[raise ValueError(&#39;concurrent_limit must b...]
n12[]
n13{if self.time_delay_threshold &lt;= 0}
n14[raise ValueError(&#39;time_delay_threshold mu...]
n15[]
n16{if not 0 &lt;= self.boolean_diff_...}
n17[raise ValueError(&#39;boolean_diff_threshold ...]
n18[]
n19{if not 0 &lt;= self.min_confidenc...}
n20[raise ValueError(&#39;min_confidence_score mu...]
n21[]
n22{if self.max_payload_length &lt;= 0}
n23[raise ValueError(&#39;max_payload_length must...]
n24[]
n25[valid_engines = {&#39;error&#39;, &a...]
n26{for engine in self.engines}
n27{if engine not in valid_engines}
n28[raise ValueError(f&#39;Unknown engine: {...]
n29[]
n30[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n30
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n26
n30 --> n2
1125. aiva func sqli config Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 檢測配置管理\n統一的配置類別和驗證邏輯\n']
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[class SqliConfig(...)]
n8[SqliEngineConfig = SqliConfig]
n9[SqliDetectionConfig = SqliConfig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 檢測配置管理\n統一的配置類別和驗證邏輯\n&#39;]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass, field]
n6[from typing import Any]
n7[class SqliConfig(...)]
n8[SqliEngineConfig = SqliConfig]
n9[SqliDetectionConfig = SqliConfig]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1126. aiva func sqli detection models Function str
flowchart TB
n1([開始])
n2([結束])
n3[return f'[{self.engine_name} ...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return f&#39;[{self.engine_name}	...]
n1 --> n3
n3 --> n2
1127. aiva func sqli detection models Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 檢測結果模型\n統一的檢測結果和錯誤模型,與實際引擎使用保持一致\n&am...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FindingEv...]
n7[class DetectionResult(...)]
n8[class DetectionError(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 檢測結果模型\n統一的檢測結果和錯誤模型,與實際引擎使用保持一致\n&am...]
n4[from __future__ import annotations]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FindingEv...]
n7[class DetectionResult(...)]
n8[class DetectionError(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1128. aiva func sqli engines init Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQL注入檢測引擎模塊\n']
n4[from .boolean_detection_engine import BooleanDetec...]
n5[from .error_detection_engine import ErrorDetection...]
n6[from .oob_detection_engine import OOBDetectionEngi...]
n7[from .time_detection_engine import TimeDetectionEn...]
n8[from .union_detection_engine import UnionDetection...]
n9[__all__ = ['ErrorDetectionEngi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQL注入檢測引擎模塊\n&#39;]
n4[from .boolean_detection_engine import BooleanDetec...]
n5[from .error_detection_engine import ErrorDetection...]
n6[from .oob_detection_engine import OOBDetectionEngi...]
n7[from .time_detection_engine import TimeDetectionEn...]
n8[from .union_detection_engine import UnionDetection...]
n9[__all__ = [&#39;ErrorDetectionEngi...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1129. aiva func sqli engines boolean detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.boolean_payloads = [("'...]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.boolean_payloads = [(&quot;&#39;...]
n1 --> n3
n3 --> n2
1130. aiva func sqli engines boolean detection engine Function analyze boolean responses
flowchart TB
n1([開始])
n2([結束])
n3['分析布林回應以檢測SQL注入']
n4{if true_response.status_code !...}
n5[return True]
n6[]
n7[true_len = len(true_response.te...]
n8[false_len = len(false_response.t...]
n9[baseline_len = len(baseline.text or...]
n10{if abs(true_len - false_len) > 50}
n11[return True]
n12[]
n13{if baseline_len > 0}
n14[true_diff = abs(true_len - basel...]
n15[false_diff = abs(false_len - base...]
n16{if abs(true_diff - false_diff)...}
n17[return True]
n18[]
n19[]
n20[true_time = getattr(true_respons...]
n21[false_time = getattr(false_respon...]
n22{if true_time and false_time}
n23[time_diff = abs(true_time.total_...]
n24{if time_diff > 2.0}
n25[return True]
n26[]
n27[]
n28[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n27
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析布林回應以檢測SQL注入&#39;]
n4{if true_response.status_code !...}
n5[return True]
n6[]
n7[true_len = len(true_response.te...]
n8[false_len = len(false_response.t...]
n9[baseline_len = len(baseline.text or...]
n10{if abs(true_len - false_len) &gt; 50}
n11[return True]
n12[]
n13{if baseline_len &gt; 0}
n14[true_diff = abs(true_len - basel...]
n15[false_diff = abs(false_len - base...]
n16{if abs(true_diff - false_diff)...}
n17[return True]
n18[]
n19[]
n20[true_time = getattr(true_respons...]
n21[false_time = getattr(false_respon...]
n22{if true_time and false_time}
n23[time_diff = abs(true_time.total_...]
n24{if time_diff &gt; 2.0}
n25[return True]
n26[]
n27[]
n28[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n27
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
1131. aiva func sqli engines boolean detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
1132. aiva func sqli engines boolean detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n布林檢測引擎 - 基於布林邏輯的SQL注入檢測\n']
n4[from __future__ import annotations]
n5[import asyncio]
n6[from typing import cast]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class BooleanDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n布林檢測引擎 - 基於布林邏輯的SQL注入檢測\n&#39;]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from typing import cast]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class BooleanDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1133. aiva func sqli engines error detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.error_patterns = {'mysql...]
n4[self.error_payloads = ["'&qu...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.error_patterns = {&#39;mysql&#3...]
n4[self.error_payloads = [&quot;&#39;&qu...]
n1 --> n3
n3 --> n4
n4 --> n2
1134. aiva func sqli engines error detection engine Function analyze error response
flowchart TB
n1([開始])
n2([結束])
n3['分析回應中的SQL錯誤']
n4{for (db_type, patterns) in self.error_patter...}
n5{for pattern in patterns}
n6{if re.search(pattern, response...}
n7[return (db_type, True)]
n8[]
n9[]
n10[]
n11[return ('unknown', False)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n4
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;分析回應中的SQL錯誤&#39;]
n4{for (db_type, patterns) in self.error_patter...}
n5{for pattern in patterns}
n6{if re.search(pattern, response...}
n7[return (db_type, True)]
n8[]
n9[]
n10[]
n11[return (&#39;unknown&#39;, False)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n4
n10 --> n11
n11 --> n2
1135. aiva func sqli engines error detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(payl...]
n8[impact = FindingImpact(descri...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
1136. aiva func sqli engines error detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n錯誤檢測引擎 - 重構後的模組化版本\n']
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class ErrorDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n錯誤檢測引擎 - 重構後的模組化版本\n&#39;]
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class ErrorDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
1137. aiva func sqli engines oob detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.oast_domain = oast_domain]
n4[self.oob_payloads = {'mysql'...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.oast_domain = oast_domain]
n4[self.oob_payloads = {&#39;mysql&#39;...]
n1 --> n3
n3 --> n4
n4 --> n2
1138. aiva func sqli engines oob detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(requ...]
n8[impact = FindingImpact(busine...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[vulnerability = Vulnerability(name=V...]
n7[evidence = FindingEvidence(requ...]
n8[impact = FindingImpact(busine...]
n9[recommendation = FindingRecommendatio...]
n10[target = FindingTarget(url=st...]
n11[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
1139. aiva func sqli engines oob detection engine Function check oob response
flowchart TB
n1([開始])
n2([結束])
n3['檢查回應中的OOB指示器']
n4[response_text = response.text or '']
n5{if subdomain in response_text}
n6[return True]
n7[]
n8[network_error_patterns = ['could not conn...]
n9{for pattern in network_error_pat...}
n10{if re.search(pattern, response...}
n11[return True]
n12[]
n13[]
n14[oob_error_patterns = ['xp_dirtree&...]
n15{for pattern in oob_error_patterns}
n16{if re.search(pattern, response...}
n17[return True]
n18[]
n19[]
n20[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n19
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n15
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查回應中的OOB指示器&#39;]
n4[response_text = response.text or &#39;&#39;]
n5{if subdomain in response_text}
n6[return True]
n7[]
n8[network_error_patterns = [&#39;could not conn...]
n9{for pattern in network_error_pat...}
n10{if re.search(pattern, response...}
n11[return True]
n12[]
n13[]
n14[oob_error_patterns = [&#39;xp_dirtree&...]
n15{for pattern in oob_error_patterns}
n16{if re.search(pattern, response...}
n17[return True]
n18[]
n19[]
n20[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n13
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n9
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n19
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n15
n19 --> n20
n20 --> n2
1140. aiva func sqli engines oob detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\nOut-of-Band (OOB) 檢測引擎 - 基於外帶通道的SQ...]
n4[from __future__ import annotations]
n5[import re]
n6[import uuid]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class OOBDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nOut-of-Band (OOB) 檢測引擎 - 基於外帶通道的SQ...]
n4[from __future__ import annotations]
n5[import re]
n6[import uuid]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class OOBDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1141. aiva func sqli engines time detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.time_payloads = {'mysql'...]
n4[self.delay_threshold = 3.0]
n5[self.max_baseline_time = 2.0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.time_payloads = {&#39;mysql&#39...]
n4[self.delay_threshold = 3.0]
n5[self.max_baseline_time = 2.0]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1142. aiva func sqli engines time detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[delay = payload_time - basel...]
n7[confidence = min(0.9, delay / 5.0...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence = FindingEvidence(payl...]
n10[impact = FindingImpact(descri...]
n11[recommendation = FindingRecommendatio...]
n12[target = FindingTarget(url=ta...]
n13[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[delay = payload_time - basel...]
n7[confidence = min(0.9, delay / 5.0...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence = FindingEvidence(payl...]
n10[impact = FindingImpact(descri...]
n11[recommendation = FindingRecommendatio...]
n12[target = FindingTarget(url=ta...]
n13[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1143. aiva func sqli engines time detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n時間檢測引擎 - 基於時間延遲的SQL注入檢測\n']
n4[from __future__ import annotations]
n5[import asyncio]
n6[import time]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class TimeDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n時間檢測引擎 - 基於時間延遲的SQL注入檢測\n&#39;]
n4[from __future__ import annotations]
n5[import asyncio]
n6[import time]
n7[import httpx]
n8[from services.aiva_common.schemas import FunctionT...]
n9[from services.aiva_common.utils import get_logger]
n10[from ..detection_models import DetectionResult]
n11[from ..payload_wrapper_encoder import PayloadWrapp...]
n12[logger = get_logger(__name__)]
n13[class TimeDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1144. aiva func sqli engines union detection engine Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.union_payloads = ["' UNION ...]
n4[self.union_indicators = ['mysql.*version&...]
n5[self.column_count_errors = ['The used SEL...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.union_payloads = [&quot;&#39; UNION ...]
n4[self.union_indicators = [&#39;mysql.*version&...]
n5[self.column_count_errors = [&#39;The used SEL...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1145. aiva func sqli engines union detection engine Function build detection result
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測結果']
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[confidence_map = {'union_success&...]
n7[confidence_score = confidence_map.get(d...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence_desc = f"UNION payload '...]
n10{if detection_type == 'union_su...}
n11[evidence_desc += 'successfully executed and r...]
n12{if detection_type == 'column_c...}
n13[evidence_desc += 'triggered column count mism...]
n14{if detection_type == 'content_...}
n15[evidence_desc += 'caused significant content ...]
n16[]
n17[]
n18[]
n19[evidence = FindingEvidence(requ...]
n20[impact = FindingImpact(busine...]
n21[recommendation = FindingRecommendatio...]
n22[target = FindingTarget(url=st...]
n23[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n18
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測結果&#39;]
n4[from services.aiva_common.enums import Confidence,...]
n5[from services.aiva_common.schemas import FindingEv...]
n6[confidence_map = {&#39;union_success&...]
n7[confidence_score = confidence_map.get(d...]
n8[vulnerability = Vulnerability(name=V...]
n9[evidence_desc = f&quot;UNION payload &#39;...]
n10{if detection_type == &#39;union_su...}
n11[evidence_desc += &#39;successfully executed and r...]
n12{if detection_type == &#39;column_c...}
n13[evidence_desc += &#39;triggered column count mism...]
n14{if detection_type == &#39;content_...}
n15[evidence_desc += &#39;caused significant content ...]
n16[]
n17[]
n18[]
n19[evidence = FindingEvidence(requ...]
n20[impact = FindingImpact(busine...]
n21[recommendation = FindingRecommendatio...]
n22[target = FindingTarget(url=st...]
n23[return DetectionResult(is_vulnerable=...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n18
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n17
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n2
1146. aiva func sqli engines union detection engine Function check column count error
flowchart TB
n1([開始])
n2([結束])
n3['檢查欄位數量錯誤(表示UNION語法有效)']
n4{for pattern in self.column_count...}
n5{if re.search(pattern, content,...}
n6[return True]
n7[]
n8[]
n9[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查欄位數量錯誤(表示UNION語法有效)&#39;]
n4{for pattern in self.column_count...}
n5{if re.search(pattern, content,...}
n6[return True]
n7[]
n8[]
n9[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n4
n8 --> n9
n9 --> n2
1147. aiva func sqli engines union detection engine Function check content change
flowchart TB
n1([開始])
n2([結束])
n3['檢查內容變化(可能表示UNION成功)']
n4[baseline_len = len(baseline)]
n5[response_len = len(response)]
n6{if baseline_len > 0}
n7[length_diff = abs(response_len - b...]
n8{if length_diff > 0.2}
n9[return True]
n10[]
n11[]
n12[baseline_numbers = set(re.findall('\\...]
n13[response_numbers = set(re.findall('\\...]
n14[new_numbers = response_numbers - b...]
n15{if len(new_numbers) >= 2}
n16[sorted_numbers = sorted([int(n) for n...]
n17{if len(sorted_numbers) >= 2}
n18{for i in range(len(sorted_...}
n19{if sorted_numbers[i + 1] - sor...}
n20[return True]
n21[]
n22[]
n23[]
n24[]
n25[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n24
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n23
n18 -->|Yes| n19
n18 -->|No| n22
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n18
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查內容變化(可能表示UNION成功)&#39;]
n4[baseline_len = len(baseline)]
n5[response_len = len(response)]
n6{if baseline_len &gt; 0}
n7[length_diff = abs(response_len - b...]
n8{if length_diff &gt; 0.2}
n9[return True]
n10[]
n11[]
n12[baseline_numbers = set(re.findall(&#39;\\...]
n13[response_numbers = set(re.findall(&#39;\\...]
n14[new_numbers = response_numbers - b...]
n15{if len(new_numbers) &gt;= 2}
n16[sorted_numbers = sorted([int(n) for n...]
n17{if len(sorted_numbers) &gt;= 2}
n18{for i in range(len(sorted_...}
n19{if sorted_numbers[i + 1] - sor...}
n20[return True]
n21[]
n22[]
n23[]
n24[]
n25[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n24
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n23
n18 -->|Yes| n19
n18 -->|No| n22
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n18
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n2
1148. aiva func sqli engines union detection engine Function check union success
flowchart TB
n1([開始])
n2([結束])
n3['檢查UNION查詢是否成功']
n4[content_lower = content.lower()]
n5{for pattern in self.union_indica...}
n6{if re.search(pattern, content_...}
n7[return True]
n8[]
n9[]
n10[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢查UNION查詢是否成功&#39;]
n4[content_lower = content.lower()]
n5{for pattern in self.union_indica...}
n6{if re.search(pattern, content_...}
n7[return True]
n8[]
n9[]
n10[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n2
1149. aiva func sqli engines union detection engine Function get detection type
flowchart TB
n1([開始])
n2([結束])
n3['確定檢測類型']
n4{if union_success}
n5[return 'union_success']
n6{if column_error}
n7[return 'column_count_error']
n8{if content_change}
n9[return 'content_change']
n10[return 'unknown']
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;確定檢測類型&#39;]
n4{if union_success}
n5[return &#39;union_success&#39;]
n6{if column_error}
n7[return &#39;column_count_error&#39;]
n8{if content_change}
n9[return &#39;content_change&#39;]
n10[return &#39;unknown&#39;]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n13
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n12
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1150. aiva func sqli engines union detection engine Module
flowchart TB
n1([開始])
n2([結束])
n3['\n聯合檢測引擎 - 基於UNION查詢的SQL注入檢測\n']
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class UnionDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n聯合檢測引擎 - 基於UNION查詢的SQL注入檢測\n&#39;]
n4[from __future__ import annotations]
n5[import re]
n6[import httpx]
n7[from services.aiva_common.schemas import FunctionT...]
n8[from services.aiva_common.utils import get_logger]
n9[from ..detection_models import DetectionResult]
n10[from ..payload_wrapper_encoder import PayloadWrapp...]
n11[logger = get_logger(__name__)]
n12[class UnionDetectionEngine(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n2
1151. aiva func sqli exceptions Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.result_data = result_data]
n4[super().__init__(f'Detection resu...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.result_data = result_data]
n4[super().__init__(f&#39;Detection resu...]
n1 --> n3
n3 --> n4
n4 --> n2
1152. aiva func sqli exceptions Function str
flowchart TB
n1([開始])
n2([結束])
n3[parts = [super(SqliError, se...]
n4{if self.url}
n5[parts.append(f'(URL: {self.url...]
n6[]
n7{if self.status_code}
n8[parts.append(f'(Status: {self.st...]
n9[]
n10[return ' '.join(parts)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[parts = [super(SqliError, se...]
n4{if self.url}
n5[parts.append(f&#39;(URL: {self.url&#...]
n6[]
n7{if self.status_code}
n8[parts.append(f&#39;(Status: {self.st...]
n9[]
n10[return &#39; &#39;.join(parts)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n2
1153. aiva func sqli exceptions Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 檢測專用異常類別\n提供具體的錯誤類型和詳細的錯誤信息\n&...]
n4[from __future__ import annotations]
n5[class SqliError(...)]
n6[class EngineExecutionError(...)]
n7[class PayloadGenerationError(...)]
n8[class ConfigurationError(...)]
n9[class NetworkError(...)]
n10[class TimeoutError(...)]
n11[class ValidationError(...)]
n12[class DetectionResultError(...)]
n13[SqliDetectionError = SqliError]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 檢測專用異常類別\n提供具體的錯誤類型和詳細的錯誤信息\n&...]
n4[from __future__ import annotations]
n5[class SqliError(...)]
n6[class EngineExecutionError(...)]
n7[class PayloadGenerationError(...)]
n8[class ConfigurationError(...)]
n9[class NetworkError(...)]
n10[class TimeoutError(...)]
n11[class ValidationError(...)]
n12[class DetectionResultError(...)]
n13[SqliDetectionError = SqliError]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1154. aiva func sqli payload wrapper encoder Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._task = task]
n1 --> n3
n3 --> n2
1155. aiva func sqli payload wrapper encoder Function inject query
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parts = list(urlparse(url))]
n7[query_pairs = dict(parse_qsl(parts...]
n8[query_pairs[parameter] = value]
n9[parts[4] = urlencode(query_pair...]
n10[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3{if not parameter}
n4[return url]
n5[]
n6[parts = list(urlparse(url))]
n7[query_pairs = dict(parse_qsl(parts...]
n8[query_pairs[parameter] = value]
n9[parts[4] = urlencode(query_pair...]
n10[return urlunparse(parts)]
n1 --> n3
n3 -->|Yes| n4
n3 -->|No| n5
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1156. aiva func sqli payload wrapper encoder Function build request dump
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f'{self.method} {...]
n4{if 'headers' in self.request_k...}
n5{for (key, value) in self.request_kwar...}
n6[lines.append(f'{key}: {val...]
n7[]
n8[]
n9[body_parts = []]
n10{if 'params' in self.request_kw...}
n11[body_parts.append(f"params={self.reques...]
n12[]
n13{if 'data' in self.request_kwargs}
n14[body_parts.append(f"data={self.request_...]
n15[]
n16{if 'json' in self.request_kwargs}
n17[body_parts.append(f"json={self.request_...]
n18[]
n19{if 'content' in self.request_k...}
n20[body_parts.append(f"content={self.reque...]
n21[]
n22{if body_parts}
n23[lines.append('\n'.join(bo...]
n24[]
n25[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lines = [f&#39;{self.method} {...]
n4{if &#39;headers&#39; in self.request_k...}
n5{for (key, value) in self.request_kwar...}
n6[lines.append(f&#39;{key}: {val...]
n7[]
n8[]
n9[body_parts = []]
n10{if &#39;params&#39; in self.request_kw...}
n11[body_parts.append(f&quot;params={self.reques...]
n12[]
n13{if &#39;data&#39; in self.request_kwargs}
n14[body_parts.append(f&quot;data={self.request_...]
n15[]
n16{if &#39;json&#39; in self.request_kwargs}
n17[body_parts.append(f&quot;json={self.request_...]
n18[]
n19{if &#39;content&#39; in self.request_k...}
n20[body_parts.append(f&quot;content={self.reque...]
n21[]
n22{if body_parts}
n23[lines.append(&#39;\n&#39;.join(bo...]
n24[]
n25[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n2
1157. aiva func sqli payload wrapper encoder Function encode
flowchart TB
n1([開始])
n2([結束])
n3['將 payload 編碼為目標請求格式']
n4[target = self._task.target]
n5[method = target.method.upper(...]
n6[headers = dict(target.headers)]
n7[cookies = dict(target.cookies)]
n8[location = (target.parameter_lo...]
n9[parameter = target.parameter]
n10[request_kwargs: dict[str, Any] = {&#...]
n11{if location == 'query'}
n12[base_params = dict(parse_qsl(urlpa...]
n13{if parameter}
n14[base_params[parameter] = payload]
n15[]
n16[request_kwargs['params'] ...]
n17[url = str(target.url)]
n18{if location == 'form' and meth...}
n19[data = dict(target.form_dat...]
n20{if parameter}
n21[data[parameter] = payload]
n22[]
n23[request_kwargs['data'] = ...]
n24[url = str(target.url)]
n25{if location == 'json' and meth...}
n26[json_payload = dict(target.json_dat...]
n27{if parameter}
n28[json_payload[parameter] = payload]
n29[]
n30[request_kwargs['json'] = ...]
n31[request_kwargs.setdefault('headers&...]
n32[url = str(target.url)]
n33{if location == 'body'}
n34[body = target.body or '']
n35[request_kwargs['content']...]
n36[url = str(target.url)]
n37[url = self._inject_query(s...]
n38[]
n39[]
n40[]
n41[]
n42[request_kwargs = {k: v for k, v in re...]
n43[return EncodedPayload(url=url, method...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n18
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n41
n18 -->|Yes| n19
n18 -->|No| n25
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n40
n25 -->|Yes| n26
n25 -->|No| n33
n26 --> n27
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n39
n33 -->|Yes| n34
n33 -->|No| n37
n34 --> n35
n35 --> n36
n36 --> n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將 payload 編碼為目標請求格式&#39;]
n4[target = self._task.target]
n5[method = target.method.upper(...]
n6[headers = dict(target.headers)]
n7[cookies = dict(target.cookies)]
n8[location = (target.parameter_lo...]
n9[parameter = target.parameter]
n10[request_kwargs: dict[str, Any] = {&#...]
n11{if location == &#39;query&#39;}
n12[base_params = dict(parse_qsl(urlpa...]
n13{if parameter}
n14[base_params[parameter] = payload]
n15[]
n16[request_kwargs[&#39;params&#39;] ...]
n17[url = str(target.url)]
n18{if location == &#39;form&#39; and meth...}
n19[data = dict(target.form_dat...]
n20{if parameter}
n21[data[parameter] = payload]
n22[]
n23[request_kwargs[&#39;data&#39;] = ...]
n24[url = str(target.url)]
n25{if location == &#39;json&#39; and meth...}
n26[json_payload = dict(target.json_dat...]
n27{if parameter}
n28[json_payload[parameter] = payload]
n29[]
n30[request_kwargs[&#39;json&#39;] = ...]
n31[request_kwargs.setdefault(&#39;headers&&#...]
n32[url = str(target.url)]
n33{if location == &#39;body&#39;}
n34[body = target.body or &#39;&#39;]
n35[request_kwargs[&#39;content&#39;]...]
n36[url = str(target.url)]
n37[url = self._inject_query(s...]
n38[]
n39[]
n40[]
n41[]
n42[request_kwargs = {k: v for k, v in re...]
n43[return EncodedPayload(url=url, method...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n18
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n41
n18 -->|Yes| n19
n18 -->|No| n25
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n40
n25 -->|Yes| n26
n25 -->|No| n33
n26 --> n27
n27 -->|Yes| n28
n27 -->|No| n29
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n32
n32 --> n39
n33 -->|Yes| n34
n33 -->|No| n37
n34 --> n35
n35 --> n36
n36 --> n38
n37 --> n38
n38 --> n39
n39 --> n40
n40 --> n41
n41 --> n42
n42 --> n43
n43 --> n2
1158. aiva func sqli payload wrapper encoder Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[from typing import Any]
n6[from urllib.parse import parse_qsl, urlencode, url...]
n7[from services.aiva_common.schemas import FunctionT...]
n8[class EncodedPayload(...)]
n9[class PayloadWrapperEncoder(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[from dataclasses import dataclass]
n5[from typing import Any]
n6[from urllib.parse import parse_qsl, urlencode, url...]
n7[from services.aiva_common.schemas import FunctionT...]
n8[class EncodedPayload(...)]
n9[class PayloadWrapperEncoder(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1159. aiva func sqli result binder publisher Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or f'sqli-...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._broker = broker]
n4[self._worker_id = worker_id or f&#39;sqli-...]
n1 --> n3
n3 --> n4
n4 --> n2
1160. aiva func sqli result binder publisher Function worker id
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[return self._worker_id]
n1 --> n3
n3 --> n2
1161. aiva func sqli result binder publisher Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[from typing import Any]
n6[import uuid]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class SqliResultBinderPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import json]
n5[from typing import Any]
n6[import uuid]
n7[from services.aiva_common.enums import ModuleName,...]
n8[from services.aiva_common.mq import AbstractBroker]
n9[from services.aiva_common.schemas import AivaMessa...]
n10[from services.aiva_common.utils import new_id]
n11[class SqliResultBinderPublisher(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
1162. aiva func sqli schemas Function str
flowchart TB
n1([開始])
n2([結束])
n3['字符串表示']
n4[payload_preview = self.payload[:50] + ...]
n5[return f'[{self.engine_name} ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;字符串表示&#39;]
n4[payload_preview = self.payload[:50] + ...]
n5[return f&#39;[{self.engine_name}	...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1163. aiva func sqli schemas Function build request dump
flowchart TB
n1([開始])
n2([結束])
n3['構建請求轉儲字符串 - 用於日誌和證據']
n4[lines = [f'{self.method} {...]
n5{if 'headers' in self.request_k...}
n6{for (key, value) in self.request_kwar...}
n7[lines.append(f'{key}: {val...]
n8[]
n9[]
n10[body_parts = []]
n11{if 'params' in self.request_kw...}
n12[body_parts.append(f"params={self.reques...]
n13[]
n14{if 'data' in self.request_kwargs}
n15[body_parts.append(f"data={self.request_...]
n16[]
n17{if 'json' in self.request_kwargs}
n18[body_parts.append(f"json={self.request_...]
n19[]
n20{if 'content' in self.request_k...}
n21[body_parts.append(f"content={self.reque...]
n22[]
n23{if body_parts}
n24[lines.append('\n'.join(bo...]
n25[]
n26[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建請求轉儲字符串 - 用於日誌和證據&#39;]
n4[lines = [f&#39;{self.method} {...]
n5{if &#39;headers&#39; in self.request_k...}
n6{for (key, value) in self.request_kwar...}
n7[lines.append(f&#39;{key}: {val...]
n8[]
n9[]
n10[body_parts = []]
n11{if &#39;params&#39; in self.request_kw...}
n12[body_parts.append(f&quot;params={self.reques...]
n13[]
n14{if &#39;data&#39; in self.request_kwargs}
n15[body_parts.append(f&quot;data={self.request_...]
n16[]
n17{if &#39;json&#39; in self.request_kwargs}
n18[body_parts.append(f&quot;json={self.request_...]
n19[]
n20{if &#39;content&#39; in self.request_k...}
n21[body_parts.append(f&quot;content={self.reque...]
n22[]
n23{if body_parts}
n24[lines.append(&#39;\n&#39;.join(bo...]
n25[]
n26[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n6
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n22
n21 --> n22
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n2
1164. aiva func sqli schemas Function record detection
flowchart TB
n1([開始])
n2([結束])
n3['記錄檢測結果']
n4[self.detections += 1]
n5{if method == 'error'}
n6[self.error_based_detections += 1]
n7{if method == 'boolean'}
n8[self.blind_detections += 1]
n9{if method == 'time'}
n10[self.time_based_detections += 1]
n11{if method == 'union'}
n12[self.union_based_detections += 1]
n13{if method == 'oob'}
n14[self.oob_detections += 1]
n15[]
n16[]
n17[]
n18[]
n19[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n19
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n18
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄檢測結果&#39;]
n4[self.detections += 1]
n5{if method == &#39;error&#39;}
n6[self.error_based_detections += 1]
n7{if method == &#39;boolean&#39;}
n8[self.blind_detections += 1]
n9{if method == &#39;time&#39;}
n10[self.time_based_detections += 1]
n11{if method == &#39;union&#39;}
n12[self.union_based_detections += 1]
n13{if method == &#39;oob&#39;}
n14[self.oob_detections += 1]
n15[]
n16[]
n17[]
n18[]
n19[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n19
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n18
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n17
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
1165. aiva func sqli schemas Function record engine execution
flowchart TB
n1([開始])
n2([結束])
n3['記錄引擎執行']
n4{if engine_name not in self.eng...}
n5[self.engines_run.append(engine_name)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄引擎執行&#39;]
n4{if engine_name not in self.eng...}
n5[self.engines_run.append(engine_name)]
n6[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n2
1166. aiva func sqli schemas Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤訊息']
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤訊息&#39;]
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
1167. aiva func sqli schemas Function record payload sent
flowchart TB
n1([開始])
n2([結束])
n3['記錄載荷發送']
n4[self.payloads_sent += 1]
n5[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄載荷發送&#39;]
n4[self.payloads_sent += 1]
n5[self.attempts += 1]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1168. aiva func sqli schemas Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細報告格式(覆蓋父類方法以添加 SQLi 特定信息)']
n4[details = super().to_details(f...]
n5[details.update({'engines_run&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細報告格式(覆蓋父類方法以添加 SQLi 特定信息)&#39;]
n4[details = super().to_details(f...]
n5[details.update({&#39;engines_run&...]
n6[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1169. aiva func sqli schemas Function validate detection method
flowchart TB
n1([開始])
n2([結束])
n3['驗證檢測方法']
n4[allowed = {'error', &...]
n5{if v not in allowed}
n6[raise ValueError(f'Invalid detection_meth...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證檢測方法&#39;]
n4[allowed = {&#39;error&#39;, &...]
n5{if v not in allowed}
n6[raise ValueError(f&#39;Invalid detection_meth...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1170. aiva func sqli schemas Function validate method
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 方法']
n4[allowed = {'GET', &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f'Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 方法&#39;]
n4[allowed = {&#39;GET&#39;, &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f&#39;Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1171. aiva func sqli schemas Function validate timeout
flowchart TB
n1([開始])
n2([結束])
n3['驗證超時設置']
n4{if 'time_threshold_seconds' in...}
n5[raise ValueError('timeout_seconds must be...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證超時設置&#39;]
n4{if &#39;time_threshold_seconds&#39; in...}
n5[raise ValueError(&#39;timeout_seconds must be...]
n6[]
n7[return v]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1172. aiva func sqli schemas Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 模組專用數據合約\n定義 SQLi 檢測相關的所有數據結構,基於 Pyda...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingEv...]
n8[class SqliDetectionResult(...)]
n9[class SqliTelemetry(...)]
n10[class SqliEngineConfig(...)]
n11[class EncodedPayload(...)]
n12[class SqliDetectionContext(...)]
n13[class DetectionError(...)]
n14[DetectionResult = SqliDetectionResult]
n15[SqliExecutionTelemetry = SqliTelemetry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 模組專用數據合約\n定義 SQLi 檢測相關的所有數據結構,基於 Pyda...]
n4[from __future__ import annotations]
n5[from typing import Any]
n6[from pydantic import BaseModel, Field, field_valid...]
n7[from services.aiva_common.schemas import FindingEv...]
n8[class SqliDetectionResult(...)]
n9[class SqliTelemetry(...)]
n10[class SqliEngineConfig(...)]
n11[class EncodedPayload(...)]
n12[class SqliDetectionContext(...)]
n13[class DetectionError(...)]
n14[DetectionResult = SqliDetectionResult]
n15[SqliExecutionTelemetry = SqliTelemetry]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
1173. aiva func sqli smart detection manager Module
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
flowchart TB
n1([開始])
n2([結束])
n1 --> n2
1174. aiva func sqli task queue Function init
flowchart TB
n1([開始])
n2([結束])
n3[self._queue: asyncio.Queue[QueuedTask | None]...]
n4[self._closed = False]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self._queue: asyncio.Queue[QueuedTask | None]...]
n4[self._closed = False]
n1 --> n3
n3 --> n4
n4 --> n2
1175. aiva func sqli task queue Module
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FunctionT...]
n7[class QueuedTask(...)]
n8[class SqliTaskQueue(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[from __future__ import annotations]
n4[import asyncio]
n5[from dataclasses import dataclass]
n6[from services.aiva_common.schemas import FunctionT...]
n7[class QueuedTask(...)]
n8[class SqliTaskQueue(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1176. aiva func sqli telemetry Function add engine
flowchart TB
n1([開始])
n2([結束])
n3['記錄引擎執行(向後兼容別名)']
n4[self.record_engine_execution(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄引擎執行(向後兼容別名)&#39;]
n4[self.record_engine_execution(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
1177. aiva func sqli telemetry Function add error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤訊息(向後兼容別名)']
n4[self.record_error(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤訊息(向後兼容別名)&#39;]
n4[self.record_error(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
1178. aiva func sqli telemetry Function record detection
flowchart TB
n1([開始])
n2([結束])
n3['記錄檢測結果']
n4[self.detections += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄檢測結果&#39;]
n4[self.detections += 1]
n1 --> n3
n3 --> n4
n4 --> n2
1179. aiva func sqli telemetry Function record engine execution
flowchart TB
n1([開始])
n2([結束])
n3['記錄引擎執行']
n4[self.engines_run.append(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄引擎執行&#39;]
n4[self.engines_run.append(engine_name)]
n1 --> n3
n3 --> n4
n4 --> n2
1180. aiva func sqli telemetry Function record error
flowchart TB
n1([開始])
n2([結束])
n3['記錄錯誤訊息']
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄錯誤訊息&#39;]
n4[self.errors.append(error_message)]
n1 --> n3
n3 --> n4
n4 --> n2
1181. aiva func sqli telemetry Function record payload sent
flowchart TB
n1([開始])
n2([結束])
n3['記錄載荷發送']
n4[self.payloads_sent += 1]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;記錄載荷發送&#39;]
n4[self.payloads_sent += 1]
n1 --> n3
n3 --> n4
n4 --> n2
1182. aiva func sqli telemetry Function to details
flowchart TB
n1([開始])
n2([結束])
n3['轉換為詳細的遙測報告格式']
n4[details: dict[str, object] = {'f...]
n5{if self.engines_run}
n6[details['engines'] = list...]
n7[]
n8{if self.errors}
n9[details['errors'] = self....]
n10[]
n11[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;轉換為詳細的遙測報告格式&#39;]
n4[details: dict[str, object] = {&#39;f...]
n5{if self.engines_run}
n6[details[&#39;engines&#39;] = list...]
n7[]
n8{if self.errors}
n9[details[&#39;errors&#39;] = self....]
n10[]
n11[return details]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n2
1183. aiva func sqli telemetry Module
flowchart TB
n1([開始])
n2([結束])
n3['\nSQLi 執行遙測數據模型\n分離遙測邏輯以避免循環導入\n']
n4[from dataclasses import dataclass, field]
n5[class SqliExecutionTelemetry(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\nSQLi 執行遙測數據模型\n分離遙測邏輯以避免循環導入\n&#39;]
n4[from dataclasses import dataclass, field]
n5[class SqliExecutionTelemetry(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1184. aiva func sqli worker Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1185. aiva func sqli worker Function create config from strategy
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據掃描策略動態創建引擎配置\n\n Args:\n ...]
n4[strategy_upper = strategy.upper()]
n5{if strategy_upper == 'FAST'}
n6[return SqliEngineConfig(timeout_secon...]
n7{if strategy_upper == 'NORMAL'}
n8[return SqliEngineConfig(timeout_secon...]
n9{if strategy_upper == 'DEEP'}
n10[return SqliEngineConfig(timeout_secon...]
n11{if strategy_upper == 'AGGRESSIVE'}
n12[return SqliEngineConfig(timeout_secon...]
n13[logger.warning(f"Unknown strategy &#...]
n14[return SqliEngineConfig()]
n15[]
n16[]
n17[]
n18[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n18
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n17
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n16
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據掃描策略動態創建引擎配置\n\n Args:\n ...]
n4[strategy_upper = strategy.upper()]
n5{if strategy_upper == &#39;FAST&#39;}
n6[return SqliEngineConfig(timeout_secon...]
n7{if strategy_upper == &#39;NORMAL&#39;}
n8[return SqliEngineConfig(timeout_secon...]
n9{if strategy_upper == &#39;DEEP&#39;}
n10[return SqliEngineConfig(timeout_secon...]
n11{if strategy_upper == &#39;AGGRESSIVE&#39;}
n12[return SqliEngineConfig(timeout_secon...]
n13[logger.warning(f&quot;Unknown strategy &#...]
n14[return SqliEngineConfig()]
n15[]
n16[]
n17[]
n18[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n18
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n17
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n16
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n2
1186. aiva func sqli worker Function setup default engines
flowchart TB
n1([開始])
n2([結束])
n3['設置預設檢測引擎']
n4{if self.config.enable_error_de...}
n5[self.register_engine('error',...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine('boolean'...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine('time', ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine('union',...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine('oob', O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置預設檢測引擎&#39;]
n4{if self.config.enable_error_de...}
n5[self.register_engine(&#39;error&#39;,...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine(&#39;boolean&#39...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine(&#39;time&#39;, ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine(&#39;union&#39;,...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine(&#39;oob&#39;, O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
1187. aiva func sqli worker Function register engine
flowchart TB
n1([開始])
n2([結束])
n3['註冊檢測引擎']
n4[self._engines[name] = engine]
n5[logger.debug(f'Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊檢測引擎&#39;]
n4[self._engines[name] = engine]
n5[logger.debug(f&#39;Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1188. aiva func sqli worker Function unregister engine
flowchart TB
n1([開始])
n2([結束])
n3['取消註冊檢測引擎']
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f'Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取消註冊檢測引擎&#39;]
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f&#39;Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
1189. aiva func sqli worker legacy Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.orchestrator = orchestrator or Sqli...]
n4[self.publisher = publisher]
n5[self.config = config or SqliEngine...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1190. aiva func sqli worker legacy Function setup default engines
flowchart TB
n1([開始])
n2([結束])
n3['設置預設檢測引擎']
n4{if self.config.enable_error_de...}
n5[self.register_engine('error',...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine('boolean'...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine('time', ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine('union',...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine('oob', O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;設置預設檢測引擎&#39;]
n4{if self.config.enable_error_de...}
n5[self.register_engine(&#39;error&#39;,...]
n6[]
n7{if self.config.enable_boolean_...}
n8[self.register_engine(&#39;boolean&#39...]
n9[]
n10{if self.config.enable_time_det...}
n11[self.register_engine(&#39;time&#39;, ...]
n12[]
n13{if self.config.enable_union_de...}
n14[self.register_engine(&#39;union&#39;,...]
n15[]
n16{if self.config.enable_oob_dete...}
n17[self.register_engine(&#39;oob&#39;, O...]
n18[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n18
n17 --> n18
n18 --> n2
1191. aiva func sqli worker legacy Function register engine
flowchart TB
n1([開始])
n2([結束])
n3['註冊檢測引擎']
n4[self._engines[name] = engine]
n5[logger.debug(f'Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;註冊檢測引擎&#39;]
n4[self._engines[name] = engine]
n5[logger.debug(f&#39;Registered detection engin...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1192. aiva func sqli worker legacy Function unregister engine
flowchart TB
n1([開始])
n2([結束])
n3['取消註冊檢測引擎']
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f'Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;取消註冊檢測引擎&#39;]
n4{if name in self._engines}
n5[del self._engines[name]]
n6[logger.debug(f&#39;Unregistered detection eng...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
1193. aiva func sqli worker legacy Module
flowchart TB
n1([開始])
n2([結束])
n3['\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliDetectionContext(...)]
n23[class SqliDetectionOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliDetectionContext(...)]
n23[class SqliDetectionOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n2
1194. aiva func sqli worker Module
flowchart TB
n1([開始])
n2([結束])
n3['\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliContext(...)]
n23[class SqliOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n29[SqliDetectionContext = SqliContext]
n30[SqliDetectionOrchestrator = SqliOrchestrator]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n重構的 SQLi Worker - 實現依賴注入和責任分離\n這是原始 worker...]
n4[from __future__ import annotations]
n5[import asyncio]
n6[from dataclasses import dataclass, field]
n7[from typing import Protocol]
n8[import httpx]
n9[from services.aiva_common.enums import Topic]
n10[from services.aiva_common.mq import get_broker]
n11[from services.aiva_common.schemas import AivaMessa...]
n12[from services.aiva_common.utils import get_logger,...]
n13[from .detection_models import DetectionResult]
n14[from .engines import BooleanDetectionEngine, Error...]
n15[from .result_binder_publisher import SqliResultBin...]
n16[from .task_queue import QueuedTask, SqliTaskQueue]
n17[from .telemetry import SqliExecutionTelemetry]
n18[logger = get_logger(__name__)]
n19[DEFAULT_TIMEOUT_SECONDS = 20.0]
n20[class DetectionEngineProtocol(...)]
n21[class SqliEngineConfig(...)]
n22[class SqliContext(...)]
n23[class SqliOrchestrator(...)]
n24[class SqliWorkerService(...)]
n25[def run(...)]
n26[def _consume_queue(...)]
n27[def _execute_task(...)]
n28[def process_task(...)]
n29[SqliDetectionContext = SqliContext]
n30[SqliDetectionOrchestrator = SqliOrchestrator]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n2
1195. authentication manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.auth = auth]
n1 --> n3
n3 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.auth = auth]
n1 --> n3
n3 --> n2
1196. config control center Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化配置控制中心\n\n Args:\n ...]
n4[self._config = config or ScanModule...]
n5[self._config_history: list[ScanModuleConfig] = ...]
n6[self._validate_config()]
n7[logger.info('ConfigControlCenter initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化配置控制中心\n\n Args:\n ...]
n4[self._config = config or ScanModule...]
n5[self._config_history: list[ScanModuleConfig] = &#...]
n6[self._validate_config()]
n7[logger.info(&#39;ConfigControlCenter initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1197. config control center Function dataclass to dict
flowchart TB
n1([開始])
n2([結束])
n3['將 dataclass 轉換為字典']
n4{if not hasattr(obj, '__datacla...}
n5[return obj]
n6[]
n7[result = {}]
n8{for field_name in obj.__dataclass_f...}
n9[value = getattr(obj, field_n...]
n10{if hasattr(value, '__dataclass...}
n11[result[field_name] = self._dataclass_to_d...]
n12[result[field_name] = value]
n13[]
n14[]
n15[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;將 dataclass 轉換為字典&#39;]
n4{if not hasattr(obj, &#39;__datacla...}
n5[return obj]
n6[]
n7[result = {}]
n8{for field_name in obj.__dataclass_f...}
n9[value = getattr(obj, field_n...]
n10{if hasattr(value, &#39;__dataclass...}
n11[result[field_name] = self._dataclass_to_d...]
n12[result[field_name] = value]
n13[]
n14[]
n15[return result]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n14
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n8
n14 --> n15
n15 --> n2
1198. config control center Function get aggressive preset
flowchart TB
n1([開始])
n2([結束])
n3['激進模式:深度、全面、高負載']
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;激進模式:深度、全面、高負載&#39;]
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
1199. config control center Function get balanced preset
flowchart TB
n1([開始])
n2([結束])
n3['平衡模式:默認配置']
n4[return ScanModuleConfig()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;平衡模式:默認配置&#39;]
n4[return ScanModuleConfig()]
n1 --> n3
n3 --> n4
n4 --> n2
1200. config control center Function get conservative preset
flowchart TB
n1([開始])
n2([結束])
n3['保守模式:快速、安全、低負載']
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保守模式:快速、安全、低負載&#39;]
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
1201. config control center Function get deep preset
flowchart TB
n1([開始])
n2([結束])
n3['深度模式:深度爬取、全面覆蓋']
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;深度模式:深度爬取、全面覆蓋&#39;]
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
1202. config control center Function get fast preset
flowchart TB
n1([開始])
n2([結束])
n3['快速模式:高速、淺掃描']
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;快速模式:高速、淺掃描&#39;]
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
1203. config control center Function get stealth preset
flowchart TB
n1([開始])
n2([結束])
n3['隱秘模式:低速、避免檢測']
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;隱秘模式:低速、避免檢測&#39;]
n4[return ScanModuleConfig(crawling=Craw...]
n1 --> n3
n3 --> n4
n4 --> n2
1204. config control center Function save snapshot
flowchart TB
n1([開始])
n2([結束])
n3['保存當前配置快照']
n4[import copy]
n5[snapshot = copy.deepcopy(self._...]
n6[self._config_history.append(snapshot)]
n7{if len(self._config_history) > 10}
n8[self._config_history.pop(0)]
n9[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;保存當前配置快照&#39;]
n4[import copy]
n5[snapshot = copy.deepcopy(self._...]
n6[self._config_history.append(snapshot)]
n7{if len(self._config_history) &gt; 10}
n8[self._config_history.pop(0)]
n9[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n2
1205. config control center Function validate config
flowchart TB
n1([開始])
n2([結束])
n3['驗證配置有效性']
n4[crawl = self._config.crawlin...]
n5[perf = self._config.perform...]
n6{if crawl.max_depth < 1}
n7[logger.warning('max_depth < 1, set...]
n8[crawl.max_depth = 1]
n9[]
n10{if crawl.max_pages < 1}
n11[logger.warning('max_pages < 1, set...]
n12[crawl.max_pages = 1]
n13[]
n14{if perf.max_concurrent_scans < 1}
n15[logger.warning('max_concurrent_scans &...]
n16[perf.max_concurrent_scans = 1]
n17[]
n18{if self._config.dynamic.enable...}
n19[logger.warning('Dynamic scan enabled but ...]
n20[self._config.dynamic.browser_pool_size = 1]
n21[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n21
n19 --> n20
n20 --> n21
n21 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證配置有效性&#39;]
n4[crawl = self._config.crawlin...]
n5[perf = self._config.perform...]
n6{if crawl.max_depth &lt; 1}
n7[logger.warning(&#39;max_depth &lt; 1, set...]
n8[crawl.max_depth = 1]
n9[]
n10{if crawl.max_pages &lt; 1}
n11[logger.warning(&#39;max_pages &lt; 1, set...]
n12[crawl.max_pages = 1]
n13[]
n14{if perf.max_concurrent_scans &lt; 1}
n15[logger.warning(&#39;max_concurrent_scans &...]
n16[perf.max_concurrent_scans = 1]
n17[]
n18{if self._config.dynamic.enable...}
n19[logger.warning(&#39;Dynamic scan enabled but ...]
n20[self._config.dynamic.browser_pool_size = 1]
n21[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n13
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n18
n18 -->|Yes| n19
n18 -->|No| n21
n19 --> n20
n20 --> n21
n21 --> n2
1206. config control center Function apply preset
flowchart TB
n1([開始])
n2([結束])
n3['\n 應用預設配置模板\n\n Args:\n ...]
n4[self._save_snapshot()]
n5[presets = {'conservative': s...]
n6{if preset_name not in presets}
n7[logger.warning(f'Unknown preset: {pr...]
n8[return False]
n9[]
n10[preset_config = presets[preset_name]...]
n11[self._config = preset_config]
n12[self._validate_config()]
n13[logger.info(f'Applied preset: {prese...]
n14[return True]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 應用預設配置模板\n\n Args:\n ...]
n4[self._save_snapshot()]
n5[presets = {&#39;conservative&#39;: s...]
n6{if preset_name not in presets}
n7[logger.warning(f&#39;Unknown preset: {pr...]
n8[return False]
n9[]
n10[preset_config = presets[preset_name]...]
n11[self._config = preset_config]
n12[self._validate_config()]
n13[logger.info(f&#39;Applied preset: {prese...]
n14[return True]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
1207. config control center Function export config
flowchart TB
n1([開始])
n2([結束])
n3['導出配置為字典']
n4[return {'crawling': self._da...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;導出配置為字典&#39;]
n4[return {&#39;crawling&#39;: self._da...]
n1 --> n3
n3 --> n4
n4 --> n2
1208. config control center Function get config summary
flowchart TB
n1([開始])
n2([結束])
n3['獲取配置摘要(用於日誌輸出)']
n4[crawl = self._config.crawlin...]
n5[dynamic = self._config.dynamic]
n6[perf = self._config.perform...]
n7[lines = ['Configuration Summ...]
n8[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取配置摘要(用於日誌輸出)&#39;]
n4[crawl = self._config.crawlin...]
n5[dynamic = self._config.dynamic]
n6[perf = self._config.perform...]
n7[lines = [&#39;Configuration Summ...]
n8[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1209. config control center Function get config
flowchart TB
n1([開始])
n2([結束])
n3['獲取完整配置']
n4[return self._config]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取完整配置&#39;]
n4[return self._config]
n1 --> n3
n3 --> n4
n4 --> n2
1210. config control center Function get crawling config
flowchart TB
n1([開始])
n2([結束])
n3['獲取爬蟲配置']
n4[return self._config.crawling]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取爬蟲配置&#39;]
n4[return self._config.crawling]
n1 --> n3
n3 --> n4
n4 --> n2
1211. config control center Function get dynamic config
flowchart TB
n1([開始])
n2([結束])
n3['獲取動態掃描配置']
n4[return self._config.dynamic]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取動態掃描配置&#39;]
n4[return self._config.dynamic]
n1 --> n3
n3 --> n4
n4 --> n2
1212. config control center Function get fingerprint config
flowchart TB
n1([開始])
n2([結束])
n3['獲取指紋識別配置']
n4[return self._config.fingerprint]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取指紋識別配置&#39;]
n4[return self._config.fingerprint]
n1 --> n3
n3 --> n4
n4 --> n2
1213. config control center Function get performance config
flowchart TB
n1([開始])
n2([結束])
n3['獲取性能配置']
n4[return self._config.performance]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取性能配置&#39;]
n4[return self._config.performance]
n1 --> n3
n3 --> n4
n4 --> n2
1214. config control center Function get reporting config
flowchart TB
n1([開始])
n2([結束])
n3['獲取報告配置']
n4[return self._config.reporting]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取報告配置&#39;]
n4[return self._config.reporting]
n1 --> n3
n3 --> n4
n4 --> n2
1215. config control center Function get security config
flowchart TB
n1([開始])
n2([結束])
n3['獲取安全配置']
n4[return self._config.security]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取安全配置&#39;]
n4[return self._config.security]
n1 --> n3
n3 --> n4
n4 --> n2
1216. config control center Function reset to defaults
flowchart TB
n1([開始])
n2([結束])
n3['重置為默認配置']
n4[self._save_snapshot()]
n5[self._config = ScanModuleConfig()]
n6[logger.info('Reset to default configurati...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;重置為默認配置&#39;]
n4[self._save_snapshot()]
n5[self._config = ScanModuleConfig()]
n6[logger.info(&#39;Reset to default configurati...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1217. config control center Function restore previous config
flowchart TB
n1([開始])
n2([結束])
n3['\n 恢復到上一個配置快照\n\n Returns:\n ...]
n4{if not self._config_history}
n5[logger.warning('No previous configuration...]
n6[return False]
n7[]
n8[self._config = self._config_history...]
n9[logger.info('Restored previous configurat...]
n10[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 恢復到上一個配置快照\n\n Returns:\n ...]
n4{if not self._config_history}
n5[logger.warning(&#39;No previous configuration...]
n6[return False]
n7[]
n8[self._config = self._config_history...]
n9[logger.info(&#39;Restored previous configurat...]
n10[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1218. config control center Function update crawling config
flowchart TB
n1([開始])
n2([結束])
n3['\n 更新爬蟲配置\n\n Args:\n ...]
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.crawli...}
n7[setattr(self._config.crawling, key, value)]
n8[logger.debug(f'Updated crawling config: &...]
n9[logger.warning(f'Unknown crawling config ...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 更新爬蟲配置\n\n Args:\n ...]
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.crawli...}
n7[setattr(self._config.crawling, key, value)]
n8[logger.debug(f&#39;Updated crawling config: &...]
n9[logger.warning(f&#39;Unknown crawling config ...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
1219. config control center Function update dynamic config
flowchart TB
n1([開始])
n2([結束])
n3['更新動態掃描配置']
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.dynami...}
n7[setattr(self._config.dynamic, key, value)]
n8[logger.debug(f'Updated dynamic config: ...]
n9[logger.warning(f'Unknown dynamic config k...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新動態掃描配置&#39;]
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.dynami...}
n7[setattr(self._config.dynamic, key, value)]
n8[logger.debug(f&#39;Updated dynamic config: &#...]
n9[logger.warning(f&#39;Unknown dynamic config k...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
1220. config control center Function update performance config
flowchart TB
n1([開始])
n2([結束])
n3['更新性能配置']
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.perfor...}
n7[setattr(self._config.performance, key, value)]
n8[logger.debug(f'Updated performance config...]
n9[logger.warning(f'Unknown performance conf...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新性能配置&#39;]
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.perfor...}
n7[setattr(self._config.performance, key, value)]
n8[logger.debug(f&#39;Updated performance config...]
n9[logger.warning(f&#39;Unknown performance conf...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
1221. config control center Function update security config
flowchart TB
n1([開始])
n2([結束])
n3['更新安全配置']
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.securi...}
n7[setattr(self._config.security, key, value)]
n8[logger.debug(f'Updated security config: &...]
n9[logger.warning(f'Unknown security config ...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;更新安全配置&#39;]
n4[self._save_snapshot()]
n5{for (key, value) in kwargs.items()}
n6{if hasattr(self._config.securi...}
n7[setattr(self._config.security, key, value)]
n8[logger.debug(f&#39;Updated security config: &...]
n9[logger.warning(f&#39;Unknown security config ...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n5
n11 --> n2
1222. core crawling engine http client hi Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化 HTTP 客戶端\n\n Args:\n ...]
n4[self._auth = auth]
n5[self._headers = headers]
n6[self._timeout = timeout]
n7[self._pool_size = pool_size]
n8[self._rate_limiter = RateLimiter(global_r...]
n9[self._client = RetryingAsyncClient(...]
n10[logger.info(f'HTTP client initialized: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化 HTTP 客戶端\n\n Args:\n ...]
n4[self._auth = auth]
n5[self._headers = headers]
n6[self._timeout = timeout]
n7[self._pool_size = pool_size]
n8[self._rate_limiter = RateLimiter(global_r...]
n9[self._client = RetryingAsyncClient(...]
n10[logger.info(f&#39;HTTP client initialized: &#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1223. core crawling engine static content parser Function extract
flowchart TB
n1([開始])
n2([結束])
n3[assets: list[Asset] = []]
n4[forms = 0]
n5{if 'text/html' in response.hea...}
n6[soup = BeautifulSoup(respon...]
n7[forms_list = soup.find_all('form&#...]
n8{for form in forms_list}
n9{if not hasattr(form, 'get'...}
n10[continue]
n11[]
n12[action = form.get('action')]
n13{if isinstance(action, str | ty...}
n14[action_url = action or base_url]
n15[full = urljoin(base_url, ac...]
n16[continue]
n17[]
n18[params = []]
n19[input_elements = form.find_all('input...]
n20{for input_elem in input_elements}
n21{if hasattr(input_elem, 'get'&...}
n22[name = input_elem.get('name...]
n23{if isinstance(name, str)}
n24[params.append(name)]
n25[]
n26[]
n27[]
n28[assets.append(Asset(asset_id=new_id(&#...]
n29[forms += 1]
n30[]
n31[links_list = soup.find_all('a'...]
n32{for a in links_list}
n33{if not hasattr(a, 'get')}
n34[continue]
n35[]
n36[href = a.get('href')]
n37{if isinstance(href, str)}
n38[assets.append(Asset(asset_id=new_id(&#...]
n39[]
n40[]
n41[]
n42[return (assets, forms)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n41
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n30
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n27
n21 -->|Yes| n22
n21 -->|No| n26
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n20
n27 --> n28
n28 --> n29
n29 --> n8
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n40
n33 -->|Yes| n34
n33 -->|No| n35
n34 --> n35
n35 --> n36
n36 --> n37
n37 -->|Yes| n38
n37 -->|No| n39
n38 --> n39
n39 --> n32
n40 --> n41
n41 --> n42
n42 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[assets: list[Asset] = []]
n4[forms = 0]
n5{if &#39;text/html&#39; in response.hea...}
n6[soup = BeautifulSoup(respon...]
n7[forms_list = soup.find_all(&#39;form&#...]
n8{for form in forms_list}
n9{if not hasattr(form, &#39;get&#39;...}
n10[continue]
n11[]
n12[action = form.get(&#39;action&#39;)]
n13{if isinstance(action, str | ty...}
n14[action_url = action or base_url]
n15[full = urljoin(base_url, ac...]
n16[continue]
n17[]
n18[params = []]
n19[input_elements = form.find_all(&#39;input...]
n20{for input_elem in input_elements}
n21{if hasattr(input_elem, &#39;get&#39;&...}
n22[name = input_elem.get(&#39;name...]
n23{if isinstance(name, str)}
n24[params.append(name)]
n25[]
n26[]
n27[]
n28[assets.append(Asset(asset_id=new_id(&#...]
n29[forms += 1]
n30[]
n31[links_list = soup.find_all(&#39;a&#39...]
n32{for a in links_list}
n33{if not hasattr(a, &#39;get&#39;)}
n34[continue]
n35[]
n36[href = a.get(&#39;href&#39;)]
n37{if isinstance(href, str)}
n38[assets.append(Asset(asset_id=new_id(&#...]
n39[]
n40[]
n41[]
n42[return (assets, forms)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n41
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n30
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n17
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n20
n20 -->|Yes| n21
n20 -->|No| n27
n21 -->|Yes| n22
n21 -->|No| n26
n22 --> n23
n23 -->|Yes| n24
n23 -->|No| n25
n24 --> n25
n25 --> n26
n26 --> n20
n27 --> n28
n28 --> n29
n29 --> n8
n30 --> n31
n31 --> n32
n32 -->|Yes| n33
n32 -->|No| n40
n33 -->|Yes| n34
n33 -->|No| n35
n34 --> n35
n35 --> n36
n36 --> n37
n37 -->|Yes| n38
n37 -->|No| n39
n38 --> n39
n39 --> n32
n40 --> n41
n41 --> n42
n42 --> n2
1224. core crawling engine url queue manager Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化 URL 佇列管理器\n\n Args:\n ...]
n4[self._queue: deque[tuple[str, int]] = deq...]
n5[self._seen: set[str] = set()]
n6[self._processed: set[str] = set()]
n7[self.max_depth = max_depth]
n8{for url in seeds}
n9[normalized = self._normalize_url(...]
n10{if normalized}
n11[self._queue.append((normalized, 0))]
n12[self._seen.add(normalized)]
n13[logger.debug(f'Seed URL added: {norm...]
n14[]
n15[]
n16[logger.info(f'URL queue initialized with ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n15
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n8
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化 URL 佇列管理器\n\n Args:\n ...]
n4[self._queue: deque[tuple[str, int]] = deq...]
n5[self._seen: set[str] = set()]
n6[self._processed: set[str] = set()]
n7[self.max_depth = max_depth]
n8{for url in seeds}
n9[normalized = self._normalize_url(...]
n10{if normalized}
n11[self._queue.append((normalized, 0))]
n12[self._seen.add(normalized)]
n13[logger.debug(f&#39;Seed URL added: {norm...]
n14[]
n15[]
n16[logger.info(f&#39;URL queue initialized with ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n15
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n8
n15 --> n16
n16 --> n2
1225. core crawling engine url queue manager Function len
flowchart TB
n1([開始])
n2([結束])
n3['返回佇列中待處理的 URL 數量']
n4[return len(self._queue)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;返回佇列中待處理的 URL 數量&#39;]
n4[return len(self._queue)]
n1 --> n3
n3 --> n4
n4 --> n2
1226. core crawling engine url queue manager Function repr
flowchart TB
n1([開始])
n2([結束])
n3['返回佇列的字符串表示']
n4[stats = self.get_statistics(...]
n5[return f"UrlQueueManager(queued={stat...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;返回佇列的字符串表示&#39;]
n4[stats = self.get_statistics(...]
n5[return f&quot;UrlQueueManager(queued={stat...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1227. core crawling engine url queue manager Function normalize url
flowchart TB
n1([開始])
n2([結束])
n3['\n 標準化 URL 以避免重複\n\n 處理:\n ...]
n4[try]
n5[parsed = urlparse(url)]
n6{if not parsed.scheme or not pa...}
n7[return None]
n8[]
n9[normalized = parsed._replace(frag...]
n10[return normalized]
n11[]
n12[except Exception]
n13[logger.warning(f"Failed to normalize URL &am...]
n14[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n12
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
n12 --> n13
n13 --> n14
n14 --> n11
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 標準化 URL 以避免重複\n\n 處理:\n ...]
n4[try]
n5[parsed = urlparse(url)]
n6{if not parsed.scheme or not pa...}
n7[return None]
n8[]
n9[normalized = parsed._replace(frag...]
n10[return normalized]
n11[]
n12[except Exception]
n13[logger.warning(f&quot;Failed to normalize URL &am...]
n14[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n12
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
n12 --> n13
n13 --> n14
n14 --> n11
1228. core crawling engine url queue manager Function add batch
flowchart TB
n1([開始])
n2([結束])
n3['\n 批量添加 URL\n\n Args:\n ...]
n4[added_count = 0]
n5{for url in urls}
n6{if self.add(url, parent_url, d...}
n7[added_count += 1]
n8[]
n9[]
n10[logger.debug(f'Batch add: {added_cou...]
n11[return added_count]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 批量添加 URL\n\n Args:\n ...]
n4[added_count = 0]
n5{for url in urls}
n6{if self.add(url, parent_url, d...}
n7[added_count += 1]
n8[]
n9[]
n10[logger.debug(f&#39;Batch add: {added_cou...]
n11[return added_count]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n11
n11 --> n2
1229. core crawling engine url queue manager Function add
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加新的 URL 到佇列\n\n Args:\n ...]
n4{if parent_url and (not urlpars...}
n5[url = urljoin(parent_url, ...]
n6[]
n7[normalized = self._normalize_url(...]
n8{if not normalized}
n9[return False]
n10[]
n11{if normalized in self._seen or...}
n12[return False]
n13[]
n14[self._queue.append((normalized, depth))]
n15[self._seen.add(normalized)]
n16[logger.debug(f'URL added: {normalize...]
n17[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加新的 URL 到佇列\n\n Args:\n ...]
n4{if parent_url and (not urlpars...}
n5[url = urljoin(parent_url, ...]
n6[]
n7[normalized = self._normalize_url(...]
n8{if not normalized}
n9[return False]
n10[]
n11{if normalized in self._seen or...}
n12[return False]
n13[]
n14[self._queue.append((normalized, depth))]
n15[self._seen.add(normalized)]
n16[logger.debug(f&#39;URL added: {normalize...]
n17[return True]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
1230. core crawling engine url queue manager Function clear
flowchart TB
n1([開始])
n2([結束])
n3['清空佇列和所有追蹤集合']
n4[self._queue.clear()]
n5[self._seen.clear()]
n6[self._processed.clear()]
n7[logger.info('URL queue cleared...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清空佇列和所有追蹤集合&#39;]
n4[self._queue.clear()]
n5[self._seen.clear()]
n6[self._processed.clear()]
n7[logger.info(&#39;URL queue cleared&#3...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1231. core crawling engine url queue manager Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取佇列統計信息\n\n Returns:\n ...]
n4[return {'queued': len(se...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取佇列統計信息\n\n Returns:\n ...]
n4[return {&#39;queued&#39;: len(se...]
n1 --> n3
n3 --> n4
n4 --> n2
1232. core crawling engine url queue manager Function has next
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查佇列中是否還有待處理的 URL\n\n Retur...]
n4[return bool(self._queue)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查佇列中是否還有待處理的 URL\n\n Retur...]
n4[return bool(self._queue)]
n1 --> n3
n3 --> n4
n4 --> n2
1233. core crawling engine url queue manager Function is processed
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 URL 是否已經處理\n\n Args:\n ...]
n4[normalized = self._normalize_url(...]
n5[return normalized in self._processed ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 URL 是否已經處理\n\n Args:\n ...]
n4[normalized = self._normalize_url(...]
n5[return normalized in self._processed ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1234. core crawling engine url queue manager Function is seen
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 URL 是否已經見過\n\n Args:\n ...]
n4[normalized = self._normalize_url(...]
n5[return normalized in self._seen if no...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 URL 是否已經見過\n\n Args:\n ...]
n4[normalized = self._normalize_url(...]
n5[return normalized in self._seen if no...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1235. core crawling engine url queue manager Function next
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取下一個要處理的 URL\n\n Returns:\...]
n4{if not self._queue}
n5[raise IndexError('URL queue is empty&...]
n6[]
n7[(url, depth) = self._queue.popleft(...]
n8[self._processed.add(url)]
n9[logger.debug(f'Dequeued URL: {url...]
n10[return url]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取下一個要處理的 URL\n\n Returns:\...]
n4{if not self._queue}
n5[raise IndexError(&#39;URL queue is empty&...]
n6[]
n7[(url, depth) = self._queue.popleft(...]
n8[self._processed.add(url)]
n9[logger.debug(f&#39;Dequeued URL: {url...]
n10[return url]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1236. dynamic engine ajax api handler Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 AJAX/API 處理器']
n4[self.discovered_endpoints: list[dict[str, Any]...]
n5[self.api_pattern_regex = re.compile('...]
n6[logger.debug('AjaxApiHandler initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 AJAX/API 處理器&#39;]
n4[self.discovered_endpoints: list[dict[str, Any]...]
n5[self.api_pattern_regex = re.compile(&#39;...]
n6[logger.debug(&#39;AjaxApiHandler initialized&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1237. dynamic engine ajax api handler Function create api asset
flowchart TB
n1([開始])
n2([結束])
n3['\n 創建 API 端點資產\n\n Args:\n ...]
n4[asset = Asset(asset_id=new_i...]
n5[self.discovered_endpoints.append({'u...]
n6[return asset]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 創建 API 端點資產\n\n Args:\n ...]
n4[asset = Asset(asset_id=new_i...]
n5[self.discovered_endpoints.append({&#39;u...]
n6[return asset]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1238. dynamic engine ajax api handler Function is valid endpoint
flowchart TB
n1([開始])
n2([結束])
n3['\n 判斷是否為有效的 API 端點\n\n Args:\n...]
n4{if self.api_pattern_regex.sear...}
n5[return True]
n6[]
n7[static_extensions = ['.css', ...]
n8[parsed = urlparse(url)]
n9[return not any((parsed.path.lower().e...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 判斷是否為有效的 API 端點\n\n Args:\n...]
n4{if self.api_pattern_regex.sear...}
n5[return True]
n6[]
n7[static_extensions = [&#39;.css&#39;, ...]
n8[parsed = urlparse(url)]
n9[return not any((parsed.path.lower().e...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1239. dynamic engine ajax api handler Function normalize url
flowchart TB
n1([開始])
n2([結束])
n3['\n 規範化 URL\n\n Args:\n ...]
n4[try]
n5[endpoint = re.sub('\\$\\{[^}...]
n6[endpoint = re.sub('\\{[^}...]
n7{if not endpoint.startswith(('h...}
n8[endpoint = urljoin(base_url, en...]
n9[]
n10[parsed = urlparse(endpoint)]
n11{if parsed.scheme and parsed.ne...}
n12[return endpoint]
n13[]
n14[return None]
n15[]
n16[except Exception]
n17[logger.warning(f'Failed to normalize URL ...]
n18[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n16
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
n16 --> n17
n17 --> n18
n18 --> n15
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 規範化 URL\n\n Args:\n ...]
n4[try]
n5[endpoint = re.sub(&#39;\\$\\{[^}...]
n6[endpoint = re.sub(&#39;\\{[^}&#...]
n7{if not endpoint.startswith((&#39;h...}
n8[endpoint = urljoin(base_url, en...]
n9[]
n10[parsed = urlparse(endpoint)]
n11{if parsed.scheme and parsed.ne...}
n12[return endpoint]
n13[]
n14[return None]
n15[]
n16[except Exception]
n17[logger.warning(f&#39;Failed to normalize URL ...]
n18[return None]
n1 --> n3
n3 --> n4
n4 --> n5
n4 --> n16
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
n16 --> n17
n17 --> n18
n18 --> n15
1240. dynamic engine ajax api handler Function get discovered endpoints
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取已發現的端點列表\n\n Returns:\n ...]
n4[return self.discovered_endpoints.copy...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取已發現的端點列表\n\n Returns:\n ...]
n4[return self.discovered_endpoints.copy...]
n1 --> n3
n3 --> n4
n4 --> n2
1241. dynamic engine ajax api handler Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取統計信息\n\n Returns:\n ...]
n4[stats = {'total_endpoints': ...]
n5{for endpoint in self.discovered_e...}
n6[source = endpoint['source']]
n7[method = endpoint['method']]
n8[stats['by_source'][so...]
n9[stats['by_method'][me...]
n10[]
n11[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取統計信息\n\n Returns:\n ...]
n4[stats = {&#39;total_endpoints&#39;: ...]
n5{for endpoint in self.discovered_e...}
n6[source = endpoint[&#39;source&#39;]]
n7[method = endpoint[&#39;method&#39;]]
n8[stats[&#39;by_source&#39;][so...]
n9[stats[&#39;by_method&#39;][me...]
n10[]
n11[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
1242. dynamic engine dynamic content extractor Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化動態內容提取器\n\n Args:\n ...]
n4[self.config = config or Extraction...]
n5[self._network_requests: list[NetworkRequest] = ...]
n6[self._extracted_contents: list[DynamicContent] = ...]
n7[self._mutation_observer_script: str | None = None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化動態內容提取器\n\n Args:\n ...]
n4[self.config = config or Extraction...]
n5[self._network_requests: list[NetworkRequest] = &#...]
n6[self._extracted_contents: list[DynamicContent] = ...]
n7[self._mutation_observer_script: str | None = None]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1243. dynamic engine dynamic content extractor Function clear
flowchart TB
n1([開始])
n2([結束])
n3['清空已提取的內容和網絡請求']
n4[self._extracted_contents.clear()]
n5[self._network_requests.clear()]
n6[logger.debug('Cleared extracted contents ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清空已提取的內容和網絡請求&#39;]
n4[self._extracted_contents.clear()]
n5[self._network_requests.clear()]
n6[logger.debug(&#39;Cleared extracted contents ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1244. dynamic engine dynamic content extractor Function convert to assets
flowchart TB
n1([開始])
n2([結束])
n3['\n 將動態內容轉換為 Asset 對象\n\n Args:...]
n4{if contents is None}
n5[contents = self._extracted_cont...]
n6[]
n7[assets: list[Asset] = []]
n8{for content in contents}
n9[try]
n10{if content.content_type == Con...}
n11[params = []]
n12{for input_data in content.attribute...}
n13{if input_data.get('name')}
n14[params.append(input_data['name&...]
n15[]
n16[]
n17[asset = Asset(asset_id=conte...]
n18[assets.append(asset)]
n19{if content.content_type == Con...}
n20[asset = Asset(asset_id=conte...]
n21[assets.append(asset)]
n22[]
n23[]
n24[]
n25[except Exception]
n26[logger.debug(f'Failed to convert content ...]
n27[]
n28[return assets]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n27
n9 --> n10
n9 --> n25
n10 -->|Yes| n11
n10 -->|No| n19
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n12
n16 --> n17
n17 --> n18
n18 --> n23
n19 -->|Yes| n20
n19 -->|No| n22
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n8
n25 --> n26
n26 --> n24
n27 --> n28
n28 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將動態內容轉換為 Asset 對象\n\n Args:...]
n4{if contents is None}
n5[contents = self._extracted_cont...]
n6[]
n7[assets: list[Asset] = []]
n8{for content in contents}
n9[try]
n10{if content.content_type == Con...}
n11[params = []]
n12{for input_data in content.attribute...}
n13{if input_data.get(&#39;name&#39;)}
n14[params.append(input_data[&#39;name&&#...]
n15[]
n16[]
n17[asset = Asset(asset_id=conte...]
n18[assets.append(asset)]
n19{if content.content_type == Con...}
n20[asset = Asset(asset_id=conte...]
n21[assets.append(asset)]
n22[]
n23[]
n24[]
n25[except Exception]
n26[logger.debug(f&#39;Failed to convert content ...]
n27[]
n28[return assets]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n27
n9 --> n10
n9 --> n25
n10 -->|Yes| n11
n10 -->|No| n19
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n12
n16 --> n17
n17 --> n18
n18 --> n23
n19 -->|Yes| n20
n19 -->|No| n22
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 --> n8
n25 --> n26
n26 --> n24
n27 --> n28
n28 --> n2
1245. dynamic engine dynamic content extractor Function get contents by type
flowchart TB
n1([開始])
n2([結束])
n3['按類型獲取內容']
n4[return [c for c in self._extracted_co...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;按類型獲取內容&#39;]
n4[return [c for c in self._extracted_co...]
n1 --> n3
n3 --> n4
n4 --> n2
1246. dynamic engine dynamic content extractor Function get extracted contents
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有已提取的內容']
n4[return self._extracted_contents.copy(...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有已提取的內容&#39;]
n4[return self._extracted_contents.copy(...]
n1 --> n3
n3 --> n4
n4 --> n2
1247. dynamic engine dynamic content extractor Function get network requests
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有網絡請求']
n4[return self._network_requests.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有網絡請求&#39;]
n4[return self._network_requests.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1248. dynamic engine dynamic content extractor Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計信息']
n4[type_counts: dict[str, int] = {}]
n5{for content in self._extracted_c...}
n6[type_name = content.content_type...]
n7[type_counts[type_name] = type_counts.get(type...]
n8[]
n9[return {'total_contents': le...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計信息&#39;]
n4[type_counts: dict[str, int] = {}]
n5{for content in self._extracted_c...}
n6[type_name = content.content_type...]
n7[type_counts[type_name] = type_counts.get(type...]
n8[]
n9[return {&#39;total_contents&#39;: le...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
1249. dynamic engine headless browser pool Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化瀏覽器池\n\n Args:\n ...]
n4[self.config = config or PoolConfig...]
n5[self._browsers: dict[str, BrowserInstance] = ...]
n6[self._pages: dict[str, PageInstance] = {}]
n7[self._browser_semaphore = asyncio.Semaphore(se...]
n8[self._playwright: Any = None]
n9[self._is_initialized = False]
n10[self._next_browser_id = 0]
n11[self._next_page_id = 0]
n12[self._lock = asyncio.Lock()]
n13[self._stats = {'browsers_created&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化瀏覽器池\n\n Args:\n ...]
n4[self.config = config or PoolConfig...]
n5[self._browsers: dict[str, BrowserInstance] = ...]
n6[self._pages: dict[str, PageInstance] = {}]
n7[self._browser_semaphore = asyncio.Semaphore(se...]
n8[self._playwright: Any = None]
n9[self._is_initialized = False]
n10[self._next_browser_id = 0]
n11[self._next_page_id = 0]
n12[self._lock = asyncio.Lock()]
n13[self._stats = {&#39;browsers_created&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n2
1250. dynamic engine headless browser pool Function get browser info
flowchart TB
n1([開始])
n2([結束])
n3['獲取指定瀏覽器的詳細信息']
n4[browser_instance = self._browsers.get(b...]
n5{if not browser_instance}
n6[return None]
n7[]
n8[return {'browser_id': browse...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取指定瀏覽器的詳細信息&#39;]
n4[browser_instance = self._browsers.get(b...]
n5{if not browser_instance}
n6[return None]
n7[]
n8[return {&#39;browser_id&#39;: browse...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1251. dynamic engine headless browser pool Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計信息']
n4[active_browsers = sum((1 for b in self...]
n5[active_pages = sum((1 for p in self...]
n6[browser_types: dict[str, int] = defaultdict(i...]
n7{for browser in self._browsers.va...}
n8[browser_types[browser.browser_type.value] += 1]
n9[]
n10[return {'initialized': self....]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計信息&#39;]
n4[active_browsers = sum((1 for b in self...]
n5[active_pages = sum((1 for p in self...]
n6[browser_types: dict[str, int] = defaultdict(i...]
n7{for browser in self._browsers.va...}
n8[browser_types[browser.browser_type.value] += 1]
n9[]
n10[return {&#39;initialized&#39;: self....]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 --> n2
1252. dynamic engine headless browser pool Function list browsers
flowchart TB
n1([開始])
n2([結束])
n3['列出所有瀏覽器實例信息']
n4[result = []]
n5{for bid in self._browsers}
n6[info = self.get_browser_inf...]
n7{if info}
n8[result.append(info)]
n9[]
n10[]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;列出所有瀏覽器實例信息&#39;]
n4[result = []]
n5{for bid in self._browsers}
n6[info = self.get_browser_inf...]
n7{if info}
n8[result.append(info)]
n9[]
n10[]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n10
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n2
1253. dynamic engine headless browser pool Function list pages
flowchart TB
n1([開始])
n2([結束])
n3['列出所有頁面實例信息']
n4[pages_info = []]
n5{for page_instance in self._pages.values()}
n6[pages_info.append({'page_id&#...]
n7[]
n8[return pages_info]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;列出所有頁面實例信息&#39;]
n4[pages_info = []]
n5{for page_instance in self._pages.values()}
n6[pages_info.append({&#39;page_id&#...]
n7[]
n8[return pages_info]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n5
n7 --> n8
n8 --> n2
1254. dynamic engine js interaction simulator Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化 JS 互動模擬器\n\n Args:\n ...]
n4[self.max_retry = max_retry]
n5[self.default_timeout_ms = default_timeout_ms]
n6[self.enable_logging = enable_logging]
n7[self._event_queue: list[JsEvent] = []]
n8[self._results: list[InteractionResult] = []]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化 JS 互動模擬器\n\n Args:\n ...]
n4[self.max_retry = max_retry]
n5[self.default_timeout_ms = default_timeout_ms]
n6[self.enable_logging = enable_logging]
n7[self._event_queue: list[JsEvent] = []]
n8[self._results: list[InteractionResult] = []]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1255. dynamic engine js interaction simulator Function get events by type
flowchart TB
n1([開始])
n2([結束])
n3['按類型統計事件數量']
n4[stats: dict[str, int] = {}]
n5{for result in self._results}
n6[event_type = result.event.event_t...]
n7[stats[event_type] = stats.get(event_type...]
n8[]
n9[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;按類型統計事件數量&#39;]
n4[stats: dict[str, int] = {}]
n5{for result in self._results}
n6[event_type = result.event.event_t...]
n7[stats[event_type] = stats.get(event_type...]
n8[]
n9[return stats]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
1256. dynamic engine js interaction simulator Function add click
flowchart TB
n1([開始])
n2([結束])
n3['添加點擊事件']
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加點擊事件&#39;]
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1257. dynamic engine js interaction simulator Function add event
flowchart TB
n1([開始])
n2([結束])
n3['添加事件到隊列']
n4[self._event_queue.append(event)]
n5{if self.enable_logging}
n6[logger.debug(f'Added event to queue: ...]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加事件到隊列&#39;]
n4[self._event_queue.append(event)]
n5{if self.enable_logging}
n6[logger.debug(f&#39;Added event to queue: ...]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
1258. dynamic engine js interaction simulator Function add hover
flowchart TB
n1([開始])
n2([結束])
n3['添加懸停事件']
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加懸停事件&#39;]
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1259. dynamic engine js interaction simulator Function add input
flowchart TB
n1([開始])
n2([結束])
n3['添加輸入事件']
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加輸入事件&#39;]
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1260. dynamic engine js interaction simulator Function add scroll
flowchart TB
n1([開始])
n2([結束])
n3['添加滾動事件']
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加滾動事件&#39;]
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1261. dynamic engine js interaction simulator Function add submit
flowchart TB
n1([開始])
n2([結束])
n3['添加表單提交事件']
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;添加表單提交事件&#39;]
n4[event = JsEvent(event_type=I...]
n5[self.add_event(event)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1262. dynamic engine js interaction simulator Function clear queue
flowchart TB
n1([開始])
n2([結束])
n3['清空事件隊列']
n4[self._event_queue.clear()]
n5{if self.enable_logging}
n6[logger.debug('Event queue cleared&...]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清空事件隊列&#39;]
n4[self._event_queue.clear()]
n5{if self.enable_logging}
n6[logger.debug(&#39;Event queue cleared&...]
n7[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n2
1263. dynamic engine js interaction simulator Function get results
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有互動結果']
n4[return self._results.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有互動結果&#39;]
n4[return self._results.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1264. dynamic engine js interaction simulator Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計信息']
n4{if not self._results}
n5[return {'total_events': 0, &...]
n6[]
n7[successful = sum((1 for r in self...]
n8[failed = len(self._results) -...]
n9[avg_time = sum((r.execution_tim...]
n10[return {'total_events': len&...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計信息&#39;]
n4{if not self._results}
n5[return {&#39;total_events&#39;: 0, &...]
n6[]
n7[successful = sum((1 for r in self...]
n8[failed = len(self._results) -...]
n9[avg_time = sum((r.execution_tim...]
n10[return {&#39;total_events&#39;: len&...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1265. dynamic engine js interaction simulator Function get success rate
flowchart TB
n1([開始])
n2([結束])
n3['獲取成功率']
n4{if not self._results}
n5[return 0.0]
n6[]
n7[successful = sum((1 for r in self...]
n8[return successful / len(self._results...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取成功率&#39;]
n4{if not self._results}
n5[return 0.0]
n6[]
n7[successful = sum((1 for r in self...]
n8[return successful / len(self._results...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1266. fingerprint manager Function init
flowchart TB
n1([開始])
n2([結束])
n3[self.passive_fp = PassiveFingerprinter...]
n4[self.merger = FingerprintMerger()]
n5[self.collected_fingerprints: Fingerprints | None =...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[self.passive_fp = PassiveFingerprinter...]
n4[self.merger = FingerprintMerger()]
n5[self.collected_fingerprints: Fingerprints | None =...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1267. fingerprint manager Function get final fingerprints
flowchart TB
n1([開始])
n2([結束])
n3['獲取最終合併的指紋信息']
n4[return self.collected_fingerprints]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取最終合併的指紋信息&#39;]
n4[return self.collected_fingerprints]
n1 --> n3
n3 --> n4
n4 --> n2
1268. fingerprint manager Function merge
flowchart TB
n1([開始])
n2([結束])
n3['合併兩個指紋對象,使用類型安全的邏輯']
n4{if existing is None}
n5[return new]
n6[]
n7[return Fingerprints(web_server=new.we...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;合併兩個指紋對象,使用類型安全的邏輯&#39;]
n4{if existing is None}
n5[return new]
n6[]
n7[return Fingerprints(web_server=new.we...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n2
1269. fingerprint manager Function reset
flowchart TB
n1([開始])
n2([結束])
n3['重置收集器狀態']
n4[self.collected_fingerprints = None]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;重置收集器狀態&#39;]
n4[self.collected_fingerprints = None]
n1 --> n3
n3 --> n4
n4 --> n2
1270. header configuration Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化頭配置管理器\n\n Args:\n ...]
n4[self.user_headers = user_headers or {}]
n5[self._custom_user_agent = user_agent]
n6[self._rotate_user_agent = rotate_user_agent]
n7[self._include_default_headers = include_default_head...]
n8[self._current_user_agent = user_agent or self._...]
n9[logger.debug(f'HeaderConfiguration initia...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化頭配置管理器\n\n Args:\n ...]
n4[self.user_headers = user_headers or {}]
n5[self._custom_user_agent = user_agent]
n6[self._rotate_user_agent = rotate_user_agent]
n7[self._include_default_headers = include_default_head...]
n8[self._current_user_agent = user_agent or self._...]
n9[logger.debug(f&#39;HeaderConfiguration initia...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1271. header configuration Function get random user agent
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取隨機 User-Agent\n\n Returns...]
n4[return random.choice(self._DEFAULT_US...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取隨機 User-Agent\n\n Returns...]
n4[return random.choice(self._DEFAULT_US...]
n1 --> n3
n3 --> n4
n4 --> n2
1272. header configuration Function add header
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加或更新一個自定義頭\n\n Args:\n ...]
n4[self.user_headers[key] = value]
n5[logger.debug(f'Added/updated header: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加或更新一個自定義頭\n\n Args:\n ...]
n4[self.user_headers[key] = value]
n5[logger.debug(f&#39;Added/updated header: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1273. header configuration Function clear custom headers
flowchart TB
n1([開始])
n2([結束])
n3['清除所有自定義頭']
n4[self.user_headers.clear()]
n5[logger.debug('Cleared all custom headers&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清除所有自定義頭&#39;]
n4[self.user_headers.clear()]
n5[logger.debug(&#39;Cleared all custom headers&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1274. header configuration Function clone
flowchart TB
n1([開始])
n2([結束])
n3['\n 克隆當前配置\n\n Returns:\n ...]
n4[new_config = HeaderConfiguration(...]
n5[return new_config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 克隆當前配置\n\n Returns:\n ...]
n4[new_config = HeaderConfiguration(...]
n5[return new_config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1275. header configuration Function create api config
flowchart TB
n1([開始])
n2([結束])
n3['\n 創建 API 請求配置\n\n Args:\n ...]
n4[headers = {'Accept': &...]
n5{if api_key}
n6[headers['X-API-Key'] = ap...]
n7[]
n8[config = cls(user_headers=hea...]
n9[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 創建 API 請求配置\n\n Args:\n ...]
n4[headers = {&#39;Accept&#39;: &&#...]
n5{if api_key}
n6[headers[&#39;X-API-Key&#39;] = ap...]
n7[]
n8[config = cls(user_headers=hea...]
n9[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n2
1276. header configuration Function create minimal config
flowchart TB
n1([開始])
n2([結束])
n3['\n 創建最小配置(只有必要的頭)\n\n Returns:...]
n4[config = cls(user_headers={},...]
n5[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 創建最小配置(只有必要的頭)\n\n Returns:...]
n4[config = cls(user_headers={},...]
n5[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1277. header configuration Function create stealth config
flowchart TB
n1([開始])
n2([結束])
n3['\n 創建隱秘模式配置(模擬真實瀏覽器)\n\n Retur...]
n4[config = cls(user_headers={'A...]
n5[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 創建隱秘模式配置(模擬真實瀏覽器)\n\n Retur...]
n4[config = cls(user_headers={&#39;A...]
n5[return config]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1278. header configuration Function enable user agent rotation
flowchart TB
n1([開始])
n2([結束])
n3['\n 啟用或禁用 User-Agent 輪換\n\n Arg...]
n4[self._rotate_user_agent = enable]
n5[logger.debug(f"User-Agent rotation: {...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 啟用或禁用 User-Agent 輪換\n\n Arg...]
n4[self._rotate_user_agent = enable]
n5[logger.debug(f&quot;User-Agent rotation: {&#...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1279. header configuration Function from dict
flowchart TB
n1([開始])
n2([結束])
n3['\n 從字典創建配置\n\n Args:\n ...]
n4[return cls(user_headers=config_dict.g...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 從字典創建配置\n\n Args:\n ...]
n4[return cls(user_headers=config_dict.g...]
n1 --> n3
n3 --> n4
n4 --> n2
1280. header configuration Function get custom headers
flowchart TB
n1([開始])
n2([結束])
n3['獲取用戶自定義的頭']
n4[return self.user_headers.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取用戶自定義的頭&#39;]
n4[return self.user_headers.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1281. header configuration Function get default headers
flowchart TB
n1([開始])
n2([結束])
n3['獲取默認的系統頭']
n4[return cls._DEFAULT_HEADERS.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取默認的系統頭&#39;]
n4[return cls._DEFAULT_HEADERS.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1282. header configuration Function get default user agents
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有默認的 User-Agent 列表']
n4[return cls._DEFAULT_USER_AGENTS.copy(...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有默認的 User-Agent 列表&#39;]
n4[return cls._DEFAULT_USER_AGENTS.copy(...]
n1 --> n3
n3 --> n4
n4 --> n2
1283. header configuration Function get headers for api
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取適合 API 請求的頭\n\n Returns:\...]
n4[headers = {'Accept': &...]
n5[headers.update(self.user_headers)]
n6[return headers]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取適合 API 請求的頭\n\n Returns:\...]
n4[headers = {&#39;Accept&#39;: &&#...]
n5[headers.update(self.user_headers)]
n6[return headers]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1284. header configuration Function get headers summary
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取頭配置摘要\n\n Returns:\n ...]
n4[lines = ['Header Configurati...]
n5{if self.user_headers}
n6[lines.append(' Custom Header Keys:&&...]
n7{for key in list(self.user_he...}
n8[lines.append(f' - {key}&...]
n9[]
n10{if len(self.user_headers) > 10}
n11[lines.append(f' ... and {len(...]
n12[]
n13[]
n14[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取頭配置摘要\n\n Returns:\n ...]
n4[lines = [&#39;Header Configurati...]
n5{if self.user_headers}
n6[lines.append(&#39; Custom Header Keys:&&...]
n7{for key in list(self.user_he...}
n8[lines.append(f&#39; - {key}&...]
n9[]
n10{if len(self.user_headers) &gt; 10}
n11[lines.append(f&#39; ... and {len(...]
n12[]
n13[]
n14[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n7
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
1285. header configuration Function get headers
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取組裝後的 HTTP 頭\n\n Args:\n ...]
n4[headers = {}]
n5{if self._include_default_headers}
n6[headers.update(self._DEFAULT_HEADERS)]
n7[]
n8{if self._rotate_user_agent}
n9[self._current_user_agent = self._get_random_use...]
n10[]
n11[headers['User-Agent'] = s...]
n12{if for_json}
n13[headers['Content-Type'] =...]
n14[headers['Accept'] = &...]
n15[]
n16[headers.update(self.user_headers)]
n17[return headers]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取組裝後的 HTTP 頭\n\n Args:\n ...]
n4[headers = {}]
n5{if self._include_default_headers}
n6[headers.update(self._DEFAULT_HEADERS)]
n7[]
n8{if self._rotate_user_agent}
n9[self._current_user_agent = self._get_random_use...]
n10[]
n11[headers[&#39;User-Agent&#39;] = s...]
n12{if for_json}
n13[headers[&#39;Content-Type&#39;] =...]
n14[headers[&#39;Accept&#39;] = &...]
n15[]
n16[headers.update(self.user_headers)]
n17[return headers]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n15
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n2
1286. header configuration Function get user agent
flowchart TB
n1([開始])
n2([結束])
n3['獲取當前的 User-Agent']
n4[return self._current_user_agent]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取當前的 User-Agent&#39;]
n4[return self._current_user_agent]
n1 --> n3
n3 --> n4
n4 --> n2
1287. header configuration Function merge headers
flowchart TB
n1([開始])
n2([結束])
n3['\n 合併額外的頭\n\n Args:\n ...]
n4[self.user_headers.update(additional_headers)]
n5[logger.debug(f'Merged {len(addit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 合併額外的頭\n\n Args:\n ...]
n4[self.user_headers.update(additional_headers)]
n5[logger.debug(f&#39;Merged {len(addit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1288. header configuration Function remove header
flowchart TB
n1([開始])
n2([結束])
n3['\n 移除一個自定義頭\n\n Args:\n ...]
n4{if key in self.user_headers}
n5[del self.user_headers[key]]
n6[logger.debug(f'Removed header: {key&...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 移除一個自定義頭\n\n Args:\n ...]
n4{if key in self.user_headers}
n5[del self.user_headers[key]]
n6[logger.debug(f&#39;Removed header: {key&...]
n7[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n2
1289. header configuration Function set authorization
flowchart TB
n1([開始])
n2([結束])
n3['\n 設置 Authorization 頭\n\n Args...]
n4[self.add_header('Authorization...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 設置 Authorization 頭\n\n Args...]
n4[self.add_header(&#39;Authorization&#3...]
n1 --> n3
n3 --> n4
n4 --> n2
1290. header configuration Function set cookie
flowchart TB
n1([開始])
n2([結束])
n3['\n 設置 Cookie 頭\n\n Args:\n ...]
n4[self.add_header('Cookie', coo...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 設置 Cookie 頭\n\n Args:\n ...]
n4[self.add_header(&#39;Cookie&#39;, coo...]
n1 --> n3
n3 --> n4
n4 --> n2
1291. header configuration Function set referer
flowchart TB
n1([開始])
n2([結束])
n3['\n 設置 Referer 頭\n\n Args:\n ...]
n4[self.add_header('Referer', re...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 設置 Referer 頭\n\n Args:\n ...]
n4[self.add_header(&#39;Referer&#39;, re...]
n1 --> n3
n3 --> n4
n4 --> n2
1292. header configuration Function set user agent
flowchart TB
n1([開始])
n2([結束])
n3['\n 設置自定義 User-Agent\n\n Args:\...]
n4[self._custom_user_agent = user_agent]
n5[self._current_user_agent = user_agent]
n6[logger.debug(f'Set custom User-Agent: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 設置自定義 User-Agent\n\n Args:\...]
n4[self._custom_user_agent = user_agent]
n5[self._current_user_agent = user_agent]
n6[logger.debug(f&#39;Set custom User-Agent: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1293. header configuration Function to dict
flowchart TB
n1([開始])
n2([結束])
n3['\n 將配置轉換為字典\n\n Returns:\n ...]
n4[return {'user_headers': self...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將配置轉換為字典\n\n Returns:\n ...]
n4[return {&#39;user_headers&#39;: self...]
n1 --> n3
n3 --> n4
n4 --> n2
1294. info gatherer javascript source analyzer Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化分析器']
n4[self._sink_patterns = self._build_sink_pat...]
n5[self._source_patterns = self._build_source_p...]
n6[self._security_patterns = self._build_security...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化分析器&#39;]
n4[self._sink_patterns = self._build_sink_pat...]
n5[self._source_patterns = self._build_source_p...]
n6[self._security_patterns = self._build_security...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1295. info gatherer javascript source analyzer Function analyze dataflow
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析數據流(簡化版)\n\n 檢測用戶輸入源是否流向危...]
n4[source_lines = {p.line_number for p...]
n5{for sink in result.sinks}
n6[nearby_sources = [line for line in so...]
n7{if nearby_sources}
n8[sink.tainted_source = f'Potential taint fr...]
n9{if sink.severity == Severity.HIGH}
n10[sink.severity = Severity.HIGH]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n5
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析數據流(簡化版)\n\n 檢測用戶輸入源是否流向危...]
n4[source_lines = {p.line_number for p...]
n5{for sink in result.sinks}
n6[nearby_sources = [line for line in so...]
n7{if nearby_sources}
n8[sink.tainted_source = f&#39;Potential taint fr...]
n9{if sink.severity == Severity.HIGH}
n10[sink.severity = Severity.HIGH]
n11[]
n12[]
n13[]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n13
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n5
n13 --> n2
1296. info gatherer javascript source analyzer Function build security patterns
flowchart TB
n1([開始])
n2([結束])
n3['構建安全問題檢測模式']
n4[return {PatternType.API_KEY: {'patt...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建安全問題檢測模式&#39;]
n4[return {PatternType.API_KEY: {&#39;patt...]
n1 --> n3
n3 --> n4
n4 --> n2
1297. info gatherer javascript source analyzer Function build sink patterns
flowchart TB
n1([開始])
n2([結束])
n3['構建 sink 檢測模式']
n4[return {SinkType.INNER_HTML: {'patt...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建 sink 檢測模式&#39;]
n4[return {SinkType.INNER_HTML: {&#39;patt...]
n1 --> n3
n3 --> n4
n4 --> n2
1298. info gatherer javascript source analyzer Function build source patterns
flowchart TB
n1([開始])
n2([結束])
n3['構建輸入源檢測模式']
n4[return {PatternType.URL_PARAMETER: {...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建輸入源檢測模式&#39;]
n4[return {PatternType.URL_PARAMETER: {&#3...]
n1 --> n3
n3 --> n4
n4 --> n2
1299. info gatherer javascript source analyzer Function count by type
flowchart TB
n1([開始])
n2([結束])
n3['按類型統計']
n4[counts: dict[str, int] = {}]
n5{for item in items}
n6{if isinstance(item, SinkMatch)}
n7[key = item.sink_type.value]
n8[key = item.pattern_type.va...]
n9[]
n10[counts[key] = counts.get(key, 0) +...]
n11[]
n12[return counts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n5
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;按類型統計&#39;]
n4[counts: dict[str, int] = {}]
n5{for item in items}
n6{if isinstance(item, SinkMatch)}
n7[key = item.sink_type.value]
n8[key = item.pattern_type.va...]
n9[]
n10[counts[key] = counts.get(key, 0) +...]
n11[]
n12[return counts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n9
n8 --> n9
n9 --> n10
n10 --> n5
n11 --> n12
n12 --> n2
1300. info gatherer javascript source analyzer Function detect patterns
flowchart TB
n1([開始])
n2([結束])
n3['檢測可疑模式']
n4[patterns: list[PatternMatch] = []]
n5{for (line_num, line) in enumerate(lines, ...}
n6[stripped = line.strip()]
n7{if not stripped or stripped.st...}
n8[continue]
n9[]
n10{for (source_type, pattern_info) in self._source_p...}
n11[pattern = pattern_info['patter...]
n12[severity = pattern_info['severi...]
n13[description = pattern_info['descri...]
n14[match = re.search(pattern, l...]
n15{if match}
n16[patterns.append(PatternMatch(pattern_type=source_...]
n17[]
n18[]
n19{for (security_type, pattern_info) in self._securi...}
n20[pattern = pattern_info['patter...]
n21[severity = pattern_info['severi...]
n22[description = pattern_info['descri...]
n23[match = re.search(pattern, l...]
n24{if match}
n25[patterns.append(PatternMatch(pattern_type=securit...]
n26[]
n27[]
n28[]
n29[return patterns]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n28
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n10
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n27
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n19
n27 --> n5
n28 --> n29
n29 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測可疑模式&#39;]
n4[patterns: list[PatternMatch] = []]
n5{for (line_num, line) in enumerate(lines, ...}
n6[stripped = line.strip()]
n7{if not stripped or stripped.st...}
n8[continue]
n9[]
n10{for (source_type, pattern_info) in self._source_p...}
n11[pattern = pattern_info[&#39;patter...]
n12[severity = pattern_info[&#39;severi...]
n13[description = pattern_info[&#39;descri...]
n14[match = re.search(pattern, l...]
n15{if match}
n16[patterns.append(PatternMatch(pattern_type=source_...]
n17[]
n18[]
n19{for (security_type, pattern_info) in self._securi...}
n20[pattern = pattern_info[&#39;patter...]
n21[severity = pattern_info[&#39;severi...]
n22[description = pattern_info[&#39;descri...]
n23[match = re.search(pattern, l...]
n24{if match}
n25[patterns.append(PatternMatch(pattern_type=securit...]
n26[]
n27[]
n28[]
n29[return patterns]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n28
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n10
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n27
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n24
n24 -->|Yes| n25
n24 -->|No| n26
n25 --> n26
n26 --> n19
n27 --> n5
n28 --> n29
n29 --> n2
1301. info gatherer javascript source analyzer Function detect sinks
flowchart TB
n1([開始])
n2([結束])
n3['檢測危險 sinks']
n4[sinks: list[SinkMatch] = []]
n5{for (line_num, line) in enumerate(lines, ...}
n6[stripped = line.strip()]
n7{if not stripped or stripped.st...}
n8[continue]
n9[]
n10{for (sink_type, pattern_info) in self._sink_patte...}
n11[pattern = pattern_info['patter...]
n12[severity = pattern_info['severi...]
n13[description = pattern_info['descri...]
n14{if re.search(pattern, line, re...}
n15[context = self._extract_contex...]
n16[sinks.append(SinkMatch(sink_type=sink_type, line_...]
n17[]
n18[]
n19[]
n20[return sinks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n19
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n10
n18 --> n5
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測危險 sinks&#39;]
n4[sinks: list[SinkMatch] = []]
n5{for (line_num, line) in enumerate(lines, ...}
n6[stripped = line.strip()]
n7{if not stripped or stripped.st...}
n8[continue]
n9[]
n10{for (sink_type, pattern_info) in self._sink_patte...}
n11[pattern = pattern_info[&#39;patter...]
n12[severity = pattern_info[&#39;severi...]
n13[description = pattern_info[&#39;descri...]
n14{if re.search(pattern, line, re...}
n15[context = self._extract_contex...]
n16[sinks.append(SinkMatch(sink_type=sink_type, line_...]
n17[]
n18[]
n19[]
n20[return sinks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n19
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n18
n11 --> n12
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n17
n15 --> n16
n16 --> n17
n17 --> n10
n18 --> n5
n19 --> n20
n20 --> n2
1302. info gatherer javascript source analyzer Function extract context
flowchart TB
n1([開始])
n2([結束])
n3['提取代碼上下文']
n4[start = max(0, line_num - wi...]
n5[end = min(len(lines), line...]
n6[context_lines = lines[start:end]]
n7[return '\n'.join((f&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;提取代碼上下文&#39;]
n4[start = max(0, line_num - wi...]
n5[end = min(len(lines), line...]
n6[context_lines = lines[start:end]]
n7[return &#39;\n&#39;.join((f&&...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1303. info gatherer javascript source analyzer Function analyze
flowchart TB
n1([開始])
n2([結束])
n3['\n 分析 JavaScript 源碼\n\n Args:\...]
n4[result = AnalysisResult(url=u...]
n5{if not source_code or not sour...}
n6[logger.debug('Empty source code provided&...]
n7[return result]
n8[]
n9[lines = source_code.split('\...]
n10[result.total_lines = len(lines)]
n11[result.sinks = self._detect_sinks(l...]
n12[result.patterns = self._detect_pattern...]
n13[self._analyze_dataflow(lines, result)]
n14[logger.info(f'Analysis complete: {le...]
n15[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 分析 JavaScript 源碼\n\n Args:\...]
n4[result = AnalysisResult(url=u...]
n5{if not source_code or not sour...}
n6[logger.debug(&#39;Empty source code provided&...]
n7[return result]
n8[]
n9[lines = source_code.split(&#39;\...]
n10[result.total_lines = len(lines)]
n11[result.sinks = self._detect_sinks(l...]
n12[result.patterns = self._detect_pattern...]
n13[self._analyze_dataflow(lines, result)]
n14[logger.info(f&#39;Analysis complete: {le...]
n15[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n2
1304. info gatherer javascript source analyzer Function format report
flowchart TB
n1([開始])
n2([結束])
n3['格式化報告']
n4[lines = []]
n5[lines.append('JavaScript Source Analysis ...]
n6[lines.append(f'URL: {result.url}...]
n7[lines.append('=' * 60)]
n8[stats = result.get_stats()]
n9[lines.append('\nStatistics:'&...]
n10[lines.append(f" Total Lines: {stats ...]
n11[lines.append(f" Total Sinks: {stats ...]
n12[lines.append(f" Total Patterns: {stats...]
n13[lines.append(f" Critical Issues: {stat...]
n14[lines.append(f" High Issues: {stats ...]
n15{if result.sinks}
n16[lines.append('\n' + &#...]
n17{for sink in result.sinks}
n18[lines.append(f'\n[{sink.severity...]
n19[lines.append(f' Line {sink.line_num...]
n20[lines.append(f' {sink.description...]
n21{if sink.tainted_source}
n22[lines.append(f' [警告] {sink...]
n23[]
n24[]
n25[]
n26{if result.patterns}
n27[lines.append('\n' + &#...]
n28{for pattern in result.patterns}
n29{if pattern.severity in [Severi...}
n30[lines.append(f'\n[{pattern.sever...]
n31[lines.append(f' Line {pattern.line_...]
n32[lines.append(f' {pattern.descriptio...]
n33[]
n34[]
n35[]
n36[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n25
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n24
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n17
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n35
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n34
n29 -->|Yes| n30
n29 -->|No| n33
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n28
n34 --> n35
n35 --> n36
n36 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;格式化報告&#39;]
n4[lines = []]
n5[lines.append(&#39;JavaScript Source Analysis ...]
n6[lines.append(f&#39;URL: {result.url}...]
n7[lines.append(&#39;=&#39; * 60)]
n8[stats = result.get_stats()]
n9[lines.append(&#39;\nStatistics:&#39;&...]
n10[lines.append(f&quot; Total Lines: {stats	...]
n11[lines.append(f&quot; Total Sinks: {stats	...]
n12[lines.append(f&quot; Total Patterns: {stats...]
n13[lines.append(f&quot; Critical Issues: {stat...]
n14[lines.append(f&quot; High Issues: {stats	...]
n15{if result.sinks}
n16[lines.append(&#39;\n&#39; + &#...]
n17{for sink in result.sinks}
n18[lines.append(f&#39;\n[{sink.severity...]
n19[lines.append(f&#39; Line {sink.line_num...]
n20[lines.append(f&#39; {sink.description&#...]
n21{if sink.tainted_source}
n22[lines.append(f&#39; [警告] {sink...]
n23[]
n24[]
n25[]
n26{if result.patterns}
n27[lines.append(&#39;\n&#39; + &#...]
n28{for pattern in result.patterns}
n29{if pattern.severity in [Severi...}
n30[lines.append(f&#39;\n[{pattern.sever...]
n31[lines.append(f&#39; Line {pattern.line_...]
n32[lines.append(f&#39; {pattern.descriptio...]
n33[]
n34[]
n35[]
n36[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n25
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n24
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n23
n22 --> n23
n23 --> n17
n24 --> n25
n25 --> n26
n26 -->|Yes| n27
n26 -->|No| n35
n27 --> n28
n28 -->|Yes| n29
n28 -->|No| n34
n29 -->|Yes| n30
n29 -->|No| n33
n30 --> n31
n31 --> n32
n32 --> n33
n33 --> n28
n34 --> n35
n35 --> n36
n36 --> n2
1305. info gatherer javascript source analyzer Function get high risk issues
flowchart TB
n1([開始])
n2([結束])
n3['獲取高風險問題']
n4[high_risk: list[SinkMatch | PatternMatch] = ...]
n5{for sink in result.sinks}
n6{if sink.severity in [Severity....}
n7[high_risk.append(sink)]
n8[]
n9[]
n10{for pattern in result.patterns}
n11{if pattern.severity in [Severi...}
n12[high_risk.append(pattern)]
n13[]
n14[]
n15[return high_risk]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n10
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取高風險問題&#39;]
n4[high_risk: list[SinkMatch | PatternMatch] = ...]
n5{for sink in result.sinks}
n6{if sink.severity in [Severity....}
n7[high_risk.append(sink)]
n8[]
n9[]
n10{for pattern in result.patterns}
n11{if pattern.severity in [Severi...}
n12[high_risk.append(pattern)]
n13[]
n14[]
n15[return high_risk]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n9
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n5
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n10
n14 --> n15
n15 --> n2
1306. info gatherer javascript source analyzer Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計信息']
n4[return {'total_sinks': len...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計信息&#39;]
n4[return {&#39;total_sinks&#39;: len&#...]
n1 --> n3
n3 --> n4
n4 --> n2
1307. info gatherer passive fingerprinter Function from headers
flowchart TB
n1([開始])
n2([結束])
n3[lower = {k.lower(): v for k,...]
n4[web_server = {'name': header...]
n5[framework = {'name': headers...]
n6[return Fingerprints(web_server=web_se...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[lower = {k.lower(): v for k,...]
n4[web_server = {&#39;name&#39;: header...]
n5[framework = {&#39;name&#39;: headers...]
n6[return Fingerprints(web_server=web_se...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1308. info gatherer sensitive info detector Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化檢測器\n\n Args:\n ...]
n4[self.min_severity = min_severity]
n5[self._patterns = self._build_patterns...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化檢測器\n\n Args:\n ...]
n4[self.min_severity = min_severity]
n5[self._patterns = self._build_patterns...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1309. info gatherer sensitive info detector Function post init
flowchart TB
n1([開始])
n2([結束])
n3['自動設置描述和建議']
n4{if not self.description}
n5[self.description = self._get_default_de...]
n6[]
n7{if not self.recommendation}
n8[self.recommendation = self._get_default_re...]
n9[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;自動設置描述和建議&#39;]
n4{if not self.description}
n5[self.description = self._get_default_de...]
n6[]
n7{if not self.recommendation}
n8[self.recommendation = self._get_default_re...]
n9[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n2
1310. info gatherer sensitive info detector Function build patterns
flowchart TB
n1([開始])
n2([結束])
n3['構建檢測模式']
n4[return {SensitiveInfoType.API_KEY: {...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;構建檢測模式&#39;]
n4[return {SensitiveInfoType.API_KEY: {&#3...]
n1 --> n3
n3 --> n4
n4 --> n2
1311. info gatherer sensitive info detector Function count by location
flowchart TB
n1([開始])
n2([結束])
n3['按位置統計']
n4[counts: dict[str, int] = {}]
n5{for match in self.matches}
n6[key = match.location.value]
n7[counts[key] = counts.get(key, 0) +...]
n8[]
n9[return counts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;按位置統計&#39;]
n4[counts: dict[str, int] = {}]
n5{for match in self.matches}
n6[key = match.location.value]
n7[counts[key] = counts.get(key, 0) +...]
n8[]
n9[return counts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
1312. info gatherer sensitive info detector Function count by type
flowchart TB
n1([開始])
n2([結束])
n3['按類型統計']
n4[counts: dict[str, int] = {}]
n5{for match in self.matches}
n6[key = match.info_type.valu...]
n7[counts[key] = counts.get(key, 0) +...]
n8[]
n9[return counts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;按類型統計&#39;]
n4[counts: dict[str, int] = {}]
n5{for match in self.matches}
n6[key = match.info_type.valu...]
n7[counts[key] = counts.get(key, 0) +...]
n8[]
n9[return counts]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n8
n6 --> n7
n7 --> n5
n8 --> n9
n9 --> n2
1313. info gatherer sensitive info detector Function detect html comments
flowchart TB
n1([開始])
n2([結束])
n3['檢測 HTML 註釋中的敏感信息']
n4[matches: list[SensitiveMatch] = []]
n5[comment_pattern = '<!--(.*?)--...]
n6{for comment_match in re.finditer(comme...}
n7[comment_text = comment_match.group(...]
n8{for match in self._detect_in_t...}
n9{if match.severity == Severity.LOW}
n10[match.severity = Severity.MEDIUM]
n11{if match.severity == Severity....}
n12[match.severity = Severity.HIGH]
n13[]
n14[]
n15[matches.append(match)]
n16[]
n17[]
n18[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n17
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n16
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n8
n16 --> n6
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 HTML 註釋中的敏感信息&#39;]
n4[matches: list[SensitiveMatch] = []]
n5[comment_pattern = &#39;&lt;!--(.*?)--...]
n6{for comment_match in re.finditer(comme...}
n7[comment_text = comment_match.group(...]
n8{for match in self._detect_in_t...}
n9{if match.severity == Severity.LOW}
n10[match.severity = Severity.MEDIUM]
n11{if match.severity == Severity....}
n12[match.severity = Severity.HIGH]
n13[]
n14[]
n15[matches.append(match)]
n16[]
n17[]
n18[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n17
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n16
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n14
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n8
n16 --> n6
n17 --> n18
n18 --> n2
1314. info gatherer sensitive info detector Function detect in text
flowchart TB
n1([開始])
n2([結束])
n3['在文本中檢測敏感信息']
n4[matches: list[SensitiveMatch] = []]
n5[lines = text.split('\n')]
n6{for (line_num, line) in enumerate(lines, ...}
n7{for (info_type, pattern_info) in self._patterns.i...}
n8[pattern = pattern_info['patter...]
n9[severity = pattern_info['severi...]
n10{for regex_match in re.finditer(patte...}
n11[matched_value = regex_match.group(0)]
n12[start = max(0, regex_match.s...]
n13[end = min(len(line), regex...]
n14[context = line[start:end]]
n15[matches.append(SensitiveMatch(info_type=info_type...]
n16[]
n17[]
n18[]
n19[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n18
n7 -->|Yes| n8
n7 -->|No| n17
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n16
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n7
n17 --> n6
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;在文本中檢測敏感信息&#39;]
n4[matches: list[SensitiveMatch] = []]
n5[lines = text.split(&#39;\n&#39;)]
n6{for (line_num, line) in enumerate(lines, ...}
n7{for (info_type, pattern_info) in self._patterns.i...}
n8[pattern = pattern_info[&#39;patter...]
n9[severity = pattern_info[&#39;severi...]
n10{for regex_match in re.finditer(patte...}
n11[matched_value = regex_match.group(0)]
n12[start = max(0, regex_match.s...]
n13[end = min(len(line), regex...]
n14[context = line[start:end]]
n15[matches.append(SensitiveMatch(info_type=info_type...]
n16[]
n17[]
n18[]
n19[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n18
n7 -->|Yes| n8
n7 -->|No| n17
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n16
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n10
n16 --> n7
n17 --> n6
n18 --> n19
n19 --> n2
1315. info gatherer sensitive info detector Function detect meta tags
flowchart TB
n1([開始])
n2([結束])
n3['檢測 meta 標籤中的敏感信息']
n4[matches: list[SensitiveMatch] = []]
n5[meta_pattern = '<meta[^> ...]
n6{for meta_match in re.finditer(meta_...}
n7[content = meta_match.group(1)]
n8{for match in self._detect_in_t...}
n9[matches.append(match)]
n10[]
n11[]
n12[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n6
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 meta 標籤中的敏感信息&#39;]
n4[matches: list[SensitiveMatch] = []]
n5[meta_pattern = &#39;&lt;meta[^&gt;	...]
n6{for meta_match in re.finditer(meta_...}
n7[content = meta_match.group(1)]
n8{for match in self._detect_in_t...}
n9[matches.append(match)]
n10[]
n11[]
n12[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n6
n11 --> n12
n12 --> n2
1316. info gatherer sensitive info detector Function detect script blocks
flowchart TB
n1([開始])
n2([結束])
n3['檢測 <script> 標籤中的敏感信息']
n4[matches: list[SensitiveMatch] = []]
n5[script_pattern = '<script[^>...]
n6{for script_match in re.finditer(scrip...}
n7[script_text = script_match.group(1...]
n8{for match in self._detect_in_t...}
n9[matches.append(match)]
n10[]
n11[]
n12[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n6
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;檢測 &lt;script&gt; 標籤中的敏感信息&#39;]
n4[matches: list[SensitiveMatch] = []]
n5[script_pattern = &#39;&lt;script[^&gt...]
n6{for script_match in re.finditer(scrip...}
n7[script_text = script_match.group(1...]
n8{for match in self._detect_in_t...}
n9[matches.append(match)]
n10[]
n11[]
n12[return matches]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n6
n11 --> n12
n12 --> n2
1317. info gatherer sensitive info detector Function filter by severity
flowchart TB
n1([開始])
n2([結束])
n3['根據最低嚴重程度過濾匹配']
n4[severity_order = {Severity.INFORMATIO...]
n5[min_level = severity_order[self....]
n6[return [m for m in matches if severit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;根據最低嚴重程度過濾匹配&#39;]
n4[severity_order = {Severity.INFORMATIO...]
n5[min_level = severity_order[self....]
n6[return [m for m in matches if severit...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1318. info gatherer sensitive info detector Function get default description
flowchart TB
n1([開始])
n2([結束])
n3['獲取默認描述']
n4[descriptions = {SensitiveInfoType.A...]
n5[return descriptions.get(self.info_typ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取默認描述&#39;]
n4[descriptions = {SensitiveInfoType.A...]
n5[return descriptions.get(self.info_typ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1319. info gatherer sensitive info detector Function get default recommendation
flowchart TB
n1([開始])
n2([結束])
n3['獲取默認建議']
n4{if self.info_type in [Sensitiv...}
n5[return 'Remove credentials from clien...]
n6{if self.info_type in [Sensitiv...}
n7[return 'Mask or remove personal infor...]
n8{if self.info_type in [Sensitiv...}
n9[return 'Disable debug mode in product...]
n10{if self.info_type == Sensitive...}
n11[return 'Remove internal file paths fr...]
n12[return 'Review and remove sensitive i...]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取默認建議&#39;]
n4{if self.info_type in [Sensitiv...}
n5[return &#39;Remove credentials from clien...]
n6{if self.info_type in [Sensitiv...}
n7[return &#39;Mask or remove personal infor...]
n8{if self.info_type in [Sensitiv...}
n9[return &#39;Disable debug mode in product...]
n10{if self.info_type == Sensitive...}
n11[return &#39;Remove internal file paths fr...]
n12[return &#39;Review and remove sensitive i...]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1320. info gatherer sensitive info detector Function detect in headers
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測 HTTP 響應頭中的敏感信息\n\n Args:...]
n4[result = DetectionResult(url=...]
n5{if not headers}
n6[return result]
n7[]
n8{for (header_name, header_value) in headers.items&...}
n9{if header_name.lower() == 'set...}
n10[result.matches.append(SensitiveMatch(info_type=Se...]
n11[]
n12[combined = f'{header_name}: {h...]
n13{for match in self._detect_in_t...}
n14[result.matches.append(match)]
n15[]
n16[]
n17[result.matches = self._filter_by_seve...]
n18[logger.info(f'Headers detection complete:...]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n16
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n13
n15 --> n8
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測 HTTP 響應頭中的敏感信息\n\n Args:...]
n4[result = DetectionResult(url=...]
n5{if not headers}
n6[return result]
n7[]
n8{for (header_name, header_value) in headers.items&...}
n9{if header_name.lower() == &#39;set...}
n10[result.matches.append(SensitiveMatch(info_type=Se...]
n11[]
n12[combined = f&#39;{header_name}: {h...]
n13{for match in self._detect_in_t...}
n14[result.matches.append(match)]
n15[]
n16[]
n17[result.matches = self._filter_by_seve...]
n18[logger.info(f&#39;Headers detection complete:...]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n16
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n13
n15 --> n8
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
1321. info gatherer sensitive info detector Function detect in html
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測 HTML 內容中的敏感信息\n\n Args:\...]
n4[result = DetectionResult(url=...]
n5{if not html_content}
n6[return result]
n7[]
n8[result.matches.extend(self._detect_html_comments(...]
n9[result.matches.extend(self._detect_script_blocks(...]
n10[result.matches.extend(self._detect_meta_tags(html...]
n11[result.matches.extend(self._detect_in_text(html_c...]
n12[result.matches = self._filter_by_seve...]
n13[logger.info(f'HTML detection complete: ...]
n14[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測 HTML 內容中的敏感信息\n\n Args:\...]
n4[result = DetectionResult(url=...]
n5{if not html_content}
n6[return result]
n7[]
n8[result.matches.extend(self._detect_html_comments(...]
n9[result.matches.extend(self._detect_script_blocks(...]
n10[result.matches.extend(self._detect_meta_tags(html...]
n11[result.matches.extend(self._detect_in_text(html_c...]
n12[result.matches = self._filter_by_seve...]
n13[logger.info(f&#39;HTML detection complete: &#...]
n14[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 --> n14
n14 --> n2
1322. info gatherer sensitive info detector Function detect in javascript
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測 JavaScript 代碼中的敏感信息\n\n ...]
n4[result = DetectionResult(url=...]
n5{if not js_code}
n6[return result]
n7[]
n8[result.matches = self._detect_in_text...]
n9[result.matches = self._filter_by_seve...]
n10[logger.info(f'JavaScript detection comple...]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測 JavaScript 代碼中的敏感信息\n\n ...]
n4[result = DetectionResult(url=...]
n5{if not js_code}
n6[return result]
n7[]
n8[result.matches = self._detect_in_text...]
n9[result.matches = self._filter_by_seve...]
n10[logger.info(f&#39;JavaScript detection comple...]
n11[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n2
1323. info gatherer sensitive info detector Function detect in response
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測完整的 HTTP 響應\n\n Args:\n ...]
n4[result = DetectionResult(url=...]
n5{if response_body}
n6{if '<html' in response_bod...}
n7[html_result = self.detect_in_html(...]
n8[result.matches.extend(html_result.matches)]
n9[body_matches = self._detect_in_text...]
n10[result.matches.extend(body_matches)]
n11[]
n12[]
n13{if headers}
n14[header_result = self.detect_in_heade...]
n15[result.matches.extend(header_result.matches)]
n16[]
n17[result.matches = self._filter_by_seve...]
n18[logger.info(f'Response detection complete...]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測完整的 HTTP 響應\n\n Args:\n ...]
n4[result = DetectionResult(url=...]
n5{if response_body}
n6{if &#39;&lt;html&#39; in response_bod...}
n7[html_result = self.detect_in_html(...]
n8[result.matches.extend(html_result.matches)]
n9[body_matches = self._detect_in_text...]
n10[result.matches.extend(body_matches)]
n11[]
n12[]
n13{if headers}
n14[header_result = self.detect_in_heade...]
n15[result.matches.extend(header_result.matches)]
n16[]
n17[result.matches = self._filter_by_seve...]
n18[logger.info(f&#39;Response detection complete...]
n19[return result]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 -->|Yes| n7
n6 -->|No| n9
n7 --> n8
n8 --> n11
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n16
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
1324. info gatherer sensitive info detector Function format report
flowchart TB
n1([開始])
n2([結束])
n3['格式化檢測報告']
n4[lines = []]
n5[lines.append('Sensitive Information Detec...]
n6[lines.append(f'URL: {result.url}...]
n7[lines.append('=' * 70)]
n8[stats = result.get_stats()]
n9[lines.append('\nStatistics:'&...]
n10[lines.append(f" Total Matches: {stats&...]
n11[lines.append(f" Critical Issues: {stat...]
n12[lines.append(f" High Issues: {stats ...]
n13{if stats['matches_by_type']}
n14[lines.append('\n Matches by Type:&...]
n15{for (info_type, count) in stats['...}
n16[lines.append(f' - {info_type}...]
n17[]
n18[]
n19{if result.matches}
n20[lines.append('\n' + &#...]
n21[sorted_matches = sorted(result.matche...]
n22{for match in sorted_matches}
n23[lines.append(f'\n[{match.severit...]
n24[lines.append(f' Location: {match.lo...]
n25{if match.line_number}
n26[lines.append(f' Line: {match.line_n...]
n27[]
n28[lines.append(f' Value: {match.value...]
n29[lines.append(f' Context: {match.con...]
n30[lines.append(f' Description: {match...]
n31[lines.append(f' Recommendation: {ma...]
n32[]
n33[]
n34[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n18
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n15
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n33
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n32
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n22
n32 --> n33
n33 --> n34
n34 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;格式化檢測報告&#39;]
n4[lines = []]
n5[lines.append(&#39;Sensitive Information Detec...]
n6[lines.append(f&#39;URL: {result.url}...]
n7[lines.append(&#39;=&#39; * 70)]
n8[stats = result.get_stats()]
n9[lines.append(&#39;\nStatistics:&#39;&...]
n10[lines.append(f&quot; Total Matches: {stats&...]
n11[lines.append(f&quot; Critical Issues: {stat...]
n12[lines.append(f&quot; High Issues: {stats	...]
n13{if stats[&#39;matches_by_type&#39;]}
n14[lines.append(&#39;\n Matches by Type:&&#...]
n15{for (info_type, count) in stats[&#39;...}
n16[lines.append(f&#39; - {info_type}...]
n17[]
n18[]
n19{if result.matches}
n20[lines.append(&#39;\n&#39; + &#...]
n21[sorted_matches = sorted(result.matche...]
n22{for match in sorted_matches}
n23[lines.append(f&#39;\n[{match.severit...]
n24[lines.append(f&#39; Location: {match.lo...]
n25{if match.line_number}
n26[lines.append(f&#39; Line: {match.line_n...]
n27[]
n28[lines.append(f&#39; Value: {match.value...]
n29[lines.append(f&#39; Context: {match.con...]
n30[lines.append(f&#39; Description: {match...]
n31[lines.append(f&#39; Recommendation: {ma...]
n32[]
n33[]
n34[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n18
n14 --> n15
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n15
n17 --> n18
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n33
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n32
n23 --> n24
n24 --> n25
n25 -->|Yes| n26
n25 -->|No| n27
n26 --> n27
n27 --> n28
n28 --> n29
n29 --> n30
n30 --> n31
n31 --> n22
n32 --> n33
n33 --> n34
n34 --> n2
1325. info gatherer sensitive info detector Function get critical issues
flowchart TB
n1([開始])
n2([結束])
n3['獲取關鍵問題']
n4[return [m for m in result.matches if ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取關鍵問題&#39;]
n4[return [m for m in result.matches if ...]
n1 --> n3
n3 --> n4
n4 --> n2
1326. info gatherer sensitive info detector Function get high risk issues
flowchart TB
n1([開始])
n2([結束])
n3['獲取高風險問題']
n4[return [m for m in result.matches if ...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取高風險問題&#39;]
n4[return [m for m in result.matches if ...]
n1 --> n3
n3 --> n4
n4 --> n2
1327. info gatherer sensitive info detector Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['獲取統計信息']
n4[return {'total_matches': len...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取統計信息&#39;]
n4[return {&#39;total_matches&#39;: len...]
n1 --> n3
n3 --> n4
n4 --> n2
1328. javascript analyzer Function init
flowchart TB
n1([開始])
n2([結束])
n3['初始化 JavaScript 分析器']
n4[self.analysis_results: list[JavaScriptAnalysisResu...]
n5[logger.debug('JavaScriptAnalyzer initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;初始化 JavaScript 分析器&#39;]
n4[self.analysis_results: list[JavaScriptAnalysisResu...]
n5[logger.debug(&#39;JavaScriptAnalyzer initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1329. javascript analyzer Function calculate security score
flowchart TB
n1([開始])
n2([結束])
n3['\n 計算安全分數(0-100)\n\n Args:\n ...]
n4[score = 100]
n5[score -= len(result.dangerous_functions) * 10]
n6{for leak in result.data_leaks}
n7[severity = leak.get('severity'...]
n8{if severity == 'critical'}
n9[score -= 25]
n10{if severity == 'high'}
n11[score -= 15]
n12{if severity == 'medium'}
n13[score -= 10]
n14[score -= 5]
n15[]
n16[]
n17[]
n18[]
n19{if len(result.external_resourc...}
n20[score -= 5]
n21[]
n22[return max(0, min(100, score))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n18
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n17
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n6
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 計算安全分數(0-100)\n\n Args:\n ...]
n4[score = 100]
n5[score -= len(result.dangerous_functions) * 10]
n6{for leak in result.data_leaks}
n7[severity = leak.get(&#39;severity&#39...]
n8{if severity == &#39;critical&#39;}
n9[score -= 25]
n10{if severity == &#39;high&#39;}
n11[score -= 15]
n12{if severity == &#39;medium&#39;}
n13[score -= 10]
n14[score -= 5]
n15[]
n16[]
n17[]
n18[]
n19{if len(result.external_resourc...}
n20[score -= 5]
n21[]
n22[return max(0, min(100, score))]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n18
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n17
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n16
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n15
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n6
n18 --> n19
n19 -->|Yes| n20
n19 -->|No| n21
n20 --> n21
n21 --> n22
n22 --> n2
1330. javascript analyzer Function detect dangerous functions
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測危險的 JavaScript 函數調用\n\n A...]
n4[dangerous_patterns = {'eval'...]
n5[detected: list[str] = []]
n6{for (func_name, pattern) in dangerous_pattern...}
n7{if re.search(pattern, js_conte...}
n8[detected.append(func_name)]
n9[logger.warning(f'Dangerous function detec...]
n10[]
n11[]
n12[return detected]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測危險的 JavaScript 函數調用\n\n A...]
n4[dangerous_patterns = {&#39;eval&#39;...]
n5[detected: list[str] = []]
n6{for (func_name, pattern) in dangerous_pattern...}
n7{if re.search(pattern, js_conte...}
n8[detected.append(func_name)]
n9[logger.warning(f&#39;Dangerous function detec...]
n10[]
n11[]
n12[return detected]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 -->|Yes| n8
n7 -->|No| n10
n8 --> n9
n9 --> n10
n10 --> n6
n11 --> n12
n12 --> n2
1331. javascript analyzer Function detect data leaks
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢測可能的數據洩漏\n\n Args:\n ...]
n4[leaks: list[dict[str, str]] = []]
n5[console_pattern = 'console\\.(log|de...]
n6[console_matches = re.finditer(console_...]
n7{if any(console_matches)}
n8[leaks.append({'type': &a...]
n9[]
n10[storage_pattern = '(localStorage|ses...]
n11[storage_matches = re.finditer(storage_...]
n12{if any(storage_matches)}
n13[leaks.append({'type': &a...]
n14[]
n15[url_param_pattern = '[?&](pas...]
n16[url_param_matches = re.finditer(url_para...]
n17{if any(url_param_matches)}
n18[leaks.append({'type': &a...]
n19[]
n20[hardcoded_pattern = '(password|apiKe...]
n21[hardcoded_matches = re.finditer(hardcode...]
n22{if any(hardcoded_matches)}
n23[leaks.append({'type': &a...]
n24[]
n25[logger.debug(f'Detected {len(lea...]
n26[return leaks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢測可能的數據洩漏\n\n Args:\n ...]
n4[leaks: list[dict[str, str]] = []]
n5[console_pattern = &#39;console\\.(log|de...]
n6[console_matches = re.finditer(console_...]
n7{if any(console_matches)}
n8[leaks.append({&#39;type&#39;: &a...]
n9[]
n10[storage_pattern = &#39;(localStorage|ses...]
n11[storage_matches = re.finditer(storage_...]
n12{if any(storage_matches)}
n13[leaks.append({&#39;type&#39;: &a...]
n14[]
n15[url_param_pattern = &#39;[?&](pas...]
n16[url_param_matches = re.finditer(url_para...]
n17{if any(url_param_matches)}
n18[leaks.append({&#39;type&#39;: &a...]
n19[]
n20[hardcoded_pattern = &#39;(password|apiKe...]
n21[hardcoded_matches = re.finditer(hardcode...]
n22{if any(hardcoded_matches)}
n23[leaks.append({&#39;type&#39;: &a...]
n24[]
n25[logger.debug(f&#39;Detected {len(lea...]
n26[return leaks]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 -->|Yes| n18
n17 -->|No| n19
n18 --> n19
n19 --> n20
n20 --> n21
n21 --> n22
n22 -->|Yes| n23
n22 -->|No| n24
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
1332. javascript analyzer Function extract external resources
flowchart TB
n1([開始])
n2([結束])
n3['\n 提取 JavaScript 中引用的外部資源\n\n ...]
n4[external_urls: list[str] = []]
n5[url_pattern = 'https?://[^\\s\\\&#...]
n6[matches = re.finditer(url_patt...]
n7{for match in matches}
n8[url = match.group(0)]
n9{if url not in external_urls}
n10[external_urls.append(url)]
n11[]
n12[]
n13[logger.debug(f'Found {len(extern...]
n14[return external_urls]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 提取 JavaScript 中引用的外部資源\n\n ...]
n4[external_urls: list[str] = []]
n5[url_pattern = &#39;https?://[^\\s\\\&#...]
n6[matches = re.finditer(url_patt...]
n7{for match in matches}
n8[url = match.group(0)]
n9{if url not in external_urls}
n10[external_urls.append(url)]
n11[]
n12[]
n13[logger.debug(f&#39;Found {len(extern...]
n14[return external_urls]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n12
n8 --> n9
n9 -->|Yes| n10
n9 -->|No| n11
n10 --> n11
n11 --> n7
n12 --> n13
n13 --> n14
n14 --> n2
1333. javascript analyzer Function clear results
flowchart TB
n1([開始])
n2([結束])
n3['清空所有分析結果']
n4[self.analysis_results.clear()]
n5[logger.debug('Cleared all JavaScript anal...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;清空所有分析結果&#39;]
n4[self.analysis_results.clear()]
n5[logger.debug(&#39;Cleared all JavaScript anal...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1334. javascript analyzer Function get all results
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取所有分析結果\n\n Returns:\n ...]
n4[return self.analysis_results.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取所有分析結果\n\n Returns:\n ...]
n4[return self.analysis_results.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1335. javascript analyzer Function get statistics
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取統計信息\n\n Returns:\n ...]
n4{if not self.analysis_results}
n5[return {'total_files': 0, &a...]
n6[]
n7[total_score = sum((r.security_scor...]
n8[total_dangerous = sum((len(r.dangerous...]
n9[total_leaks = sum((len(r.data_leak...]
n10[return {'total_files': len...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取統計信息\n\n Returns:\n ...]
n4{if not self.analysis_results}
n5[return {&#39;total_files&#39;: 0, &a...]
n6[]
n7[total_score = sum((r.security_scor...]
n8[total_dangerous = sum((len(r.dangerous...]
n9[total_leaks = sum((len(r.data_leak...]
n10[return {&#39;total_files&#39;: len&#...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1336. schemas Function init
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(**data)]
n4{if not self.description}
n5[self.description = self._get_default_de...]
n6[]
n7{if not self.recommendation}
n8[self.recommendation = self._get_default_re...]
n9[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[super().__init__(**data)]
n4{if not self.description}
n5[self.description = self._get_default_de...]
n6[]
n7{if not self.recommendation}
n8[self.recommendation = self._get_default_re...]
n9[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n2
1337. schemas Function get default description
flowchart TB
n1([開始])
n2([結束])
n3['獲取默認描述']
n4[descriptions = {SensitiveInfoType.A...]
n5[return descriptions.get(self.info_typ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取默認描述&#39;]
n4[descriptions = {SensitiveInfoType.A...]
n5[return descriptions.get(self.info_typ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1338. schemas Function get default recommendation
flowchart TB
n1([開始])
n2([結束])
n3['獲取默認建議']
n4{if self.info_type in [Sensitiv...}
n5[return 'Remove credentials from clien...]
n6{if self.info_type in [Sensitiv...}
n7[return 'Mask or remove personal infor...]
n8{if self.info_type in [Sensitiv...}
n9[return 'Disable debug mode in product...]
n10{if self.info_type == Sensitive...}
n11[return 'Remove internal file paths fr...]
n12[return f'Remove {self.info_type.value...]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取默認建議&#39;]
n4{if self.info_type in [Sensitiv...}
n5[return &#39;Remove credentials from clien...]
n6{if self.info_type in [Sensitiv...}
n7[return &#39;Mask or remove personal infor...]
n8{if self.info_type in [Sensitiv...}
n9[return &#39;Disable debug mode in product...]
n10{if self.info_type == Sensitive...}
n11[return &#39;Remove internal file paths fr...]
n12[return f&#39;Remove {self.info_type.value...]
n13[]
n14[]
n15[]
n16[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n16
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n15
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n14
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n2
1339. schemas Function limit list size
flowchart TB
n1([開始])
n2([結束])
n3['限制列表大小以防止過大的響應']
n4[max_items = 1000]
n5{if len(v) > max_items}
n6[raise ValueError(f'List too large (ma...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;限制列表大小以防止過大的響應&#39;]
n4[max_items = 1000]
n5{if len(v) &gt; max_items}
n6[raise ValueError(f&#39;List too large (ma...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1340. schemas Function limit urls
flowchart TB
n1([開始])
n2([結束])
n3['限制 URL 數量']
n4[max_urls = 500]
n5{if len(v) > max_urls}
n6[raise ValueError(f'Too many URLs (max...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;限制 URL 數量&#39;]
n4[max_urls = 500]
n5{if len(v) &gt; max_urls}
n6[raise ValueError(f&#39;Too many URLs (max...]
n7[]
n8[return v]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1341. schemas Function validate method
flowchart TB
n1([開始])
n2([結束])
n3['驗證 HTTP 方法']
n4[allowed = {'GET', &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f'Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證 HTTP 方法&#39;]
n4[allowed = {&#39;GET&#39;, &#...]
n5{if v.upper() not in allowed}
n6[raise ValueError(f&#39;Invalid HTTP method: &...]
n7[]
n8[return v.upper()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1342. schemas Function validate request type
flowchart TB
n1([開始])
n2([結束])
n3['驗證請求類型']
n4[allowed = {'xhr', &#...]
n5{if v.lower() not in allowed}
n6[raise ValueError(f'Invalid request_type: ...]
n7[]
n8[return v.lower()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;驗證請求類型&#39;]
n4[allowed = {&#39;xhr&#39;, &#...]
n5{if v.lower() not in allowed}
n6[raise ValueError(f&#39;Invalid request_type: ...]
n7[]
n8[return v.lower()]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n7
n6 --> n7
n7 --> n8
n8 --> n2
1343. scope manager Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化範圍管理器\n\n Args:\n ...]
n4[self.scope = scope]
n5[self._allowed_hosts_set = set(scope.allowed_ho...]
n6[self._exclusion_patterns = self._compile_exclus...]
n7[self._stats = {'total_checked...]
n8[logger.info(f'ScopeManager initialized: &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化範圍管理器\n\n Args:\n ...]
n4[self.scope = scope]
n5[self._allowed_hosts_set = set(scope.allowed_ho...]
n6[self._exclusion_patterns = self._compile_exclus...]
n7[self._stats = {&#39;total_checked&#3...]
n8[logger.info(f&#39;ScopeManager initialized: &...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1344. scope manager Function compile exclusion patterns
flowchart TB
n1([開始])
n2([結束])
n3['\n 編譯排除模式為正則表達式\n\n Args:\n ...]
n4[patterns = []]
n5{for exclusion in exclusions}
n6[try]
n7[pattern = self._compile_patter...]
n8[patterns.append(pattern)]
n9[]
n10[except re.error]
n11[logger.warning(f"Invalid exclusion pattern &...]
n12[]
n13[return patterns]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n6 --> n10
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 編譯排除模式為正則表達式\n\n Args:\n ...]
n4[patterns = []]
n5{for exclusion in exclusions}
n6[try]
n7[pattern = self._compile_patter...]
n8[patterns.append(pattern)]
n9[]
n10[except re.error]
n11[logger.warning(f&quot;Invalid exclusion pattern &...]
n12[]
n13[return patterns]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n12
n6 --> n7
n6 --> n10
n7 --> n8
n8 --> n9
n9 --> n5
n10 --> n11
n11 --> n9
n12 --> n13
n13 --> n2
1345. scope manager Function compile pattern
flowchart TB
n1([開始])
n2([結束])
n3['\n 將通配符模式編譯為正則表達式\n\n 支持的模式:\n...]
n4[regex = re.escape(pattern)]
n5[regex = regex.replace('\\*\\...]
n6[regex = regex.replace('\\*',...]
n7[regex = regex.replace('DOUBL...]
n8[regex = regex.replace('\\?',...]
n9[regex = f'^{regex}$']
n10[return re.compile(regex, re.IGNORECAS...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將通配符模式編譯為正則表達式\n\n 支持的模式:\n...]
n4[regex = re.escape(pattern)]
n5[regex = regex.replace(&#39;\\*\\...]
n6[regex = regex.replace(&#39;\\*&#39;,...]
n7[regex = regex.replace(&#39;DOUBL...]
n8[regex = regex.replace(&#39;\\?&#39;,...]
n9[regex = f&#39;^{regex}$&#39;]
n10[return re.compile(regex, re.IGNORECAS...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1346. scope manager Function is host allowed
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查主機名是否被允許(內部方法)\n\n Args:\...]
n4{if not hostname}
n5[return False]
n6[]
n7{if not self._allowed_hosts_set}
n8[return True]
n9[]
n10{if hostname in self._allowed_h...}
n11[return True]
n12[]
n13{if self.scope.include_subdomains}
n14{for allowed_host in self._allowed_hos...}
n15{if hostname.endswith(f'.{allow...}
n16[return True]
n17[]
n18[]
n19[]
n20[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 -->|Yes| n15
n14 -->|No| n18
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n14
n18 --> n19
n19 --> n20
n20 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查主機名是否被允許(內部方法)\n\n Args:\...]
n4{if not hostname}
n5[return False]
n6[]
n7{if not self._allowed_hosts_set}
n8[return True]
n9[]
n10{if hostname in self._allowed_h...}
n11[return True]
n12[]
n13{if self.scope.include_subdomains}
n14{for allowed_host in self._allowed_hos...}
n15{if hostname.endswith(f&#39;.{allow...}
n16[return True]
n17[]
n18[]
n19[]
n20[return False]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n9
n8 --> n9
n9 --> n10
n10 -->|Yes| n11
n10 -->|No| n12
n11 --> n12
n12 --> n13
n13 -->|Yes| n14
n13 -->|No| n19
n14 -->|Yes| n15
n14 -->|No| n18
n15 -->|Yes| n16
n15 -->|No| n17
n16 --> n17
n17 --> n14
n18 --> n19
n19 --> n20
n20 --> n2
1347. scope manager Function is valid hostname
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查主機名是否有效\n\n Args:\n ...]
n4{if not hostname}
n5[return False]
n6[]
n7[pattern = '^[a-zA-Z0-9]([a-zA...]
n8[return bool(re.match(pattern, hostnam...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查主機名是否有效\n\n Args:\n ...]
n4{if not hostname}
n5[return False]
n6[]
n7[pattern = &#39;^[a-zA-Z0-9]([a-zA...]
n8[return bool(re.match(pattern, hostnam...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1348. scope manager Function matches exclusion
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 URL 是否匹配任何排除模式\n\n Args:...]
n4[return any((pattern.search(url) for p...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 URL 是否匹配任何排除模式\n\n Args:...]
n4[return any((pattern.search(url) for p...]
n1 --> n3
n3 --> n4
n4 --> n2
1349. scope manager Function add allowed host
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加允許的主機\n\n Args:\n ...]
n4{if hostname and hostname not i...}
n5[self._allowed_hosts_set.add(hostname)]
n6[self.scope.allowed_hosts.append(hostname)]
n7[logger.info(f'Added allowed host: {h...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加允許的主機\n\n Args:\n ...]
n4{if hostname and hostname not i...}
n5[self._allowed_hosts_set.add(hostname)]
n6[self.scope.allowed_hosts.append(hostname)]
n7[logger.info(f&#39;Added allowed host: {h...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1350. scope manager Function add exclusion
flowchart TB
n1([開始])
n2([結束])
n3['\n 添加排除模式\n\n Args:\n ...]
n4{if pattern and pattern not in ...}
n5[self.scope.exclusions.append(pattern)]
n6[self._exclusion_patterns.append(self._compile_patt...]
n7[logger.info(f'Added exclusion pattern: ...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 添加排除模式\n\n Args:\n ...]
n4{if pattern and pattern not in ...}
n5[self.scope.exclusions.append(pattern)]
n6[self._exclusion_patterns.append(self._compile_patt...]
n7[logger.info(f&#39;Added exclusion pattern: &#...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1351. scope manager Function clone
flowchart TB
n1([開始])
n2([結束])
n3['\n 克隆當前範圍管理器\n\n Returns:\n ...]
n4[import copy]
n5[new_scope = copy.deepcopy(self.s...]
n6[return ScopeManager(new_scope)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 克隆當前範圍管理器\n\n Returns:\n ...]
n4[import copy]
n5[new_scope = copy.deepcopy(self.s...]
n6[return ScopeManager(new_scope)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
1352. scope manager Function filter urls
flowchart TB
n1([開始])
n2([結束])
n3['\n 過濾 URL 列表,只返回在範圍內的 URL\n\n ...]
n4[return [url for url in urls if self.i...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 過濾 URL 列表,只返回在範圍內的 URL\n\n ...]
n4[return [url for url in urls if self.i...]
n1 --> n3
n3 --> n4
n4 --> n2
1353. scope manager Function get allowed hosts
flowchart TB
n1([開始])
n2([結束])
n3['獲取允許的主機列表']
n4[return list(self._allowed_hosts_set)]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取允許的主機列表&#39;]
n4[return list(self._allowed_hosts_set)]
n1 --> n3
n3 --> n4
n4 --> n2
1354. scope manager Function get exclusions
flowchart TB
n1([開始])
n2([結束])
n3['獲取排除模式列表']
n4[return self.scope.exclusions.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取排除模式列表&#39;]
n4[return self.scope.exclusions.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1355. scope manager Function get scope summary
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取範圍配置摘要\n\n Returns:\n ...]
n4[allowed_hosts_display = ', '.join...]
n5[lines = ['Scope Configuratio...]
n6{if self.scope.exclusions}
n7[lines.append(' Exclusions:'&...]
n8{for exclusion in self.scope.exclus...}
n9[lines.append(f' - {exclusion}...]
n10[]
n11{if len(self.scope.exclusions) > 5}
n12[lines.append(f' ... and {len(...]
n13[]
n14[]
n15[stats = self.get_stats()]
n16{if stats['total_checked']...}
n17[lines.append('\n Statistics:'...]
n18[lines.append(f" Total Checked: {stat...]
n19[lines.append(f" In Scope: {stats[...]
n20[lines.append(f" Out of Scope: {stats...]
n21{if stats['total_checked']...}
n22[in_scope_percent = stats['in_scope&...]
n23[lines.append(f' In Scope %: {in_s...]
n24[]
n25[]
n26[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n14
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n25
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取範圍配置摘要\n\n Returns:\n ...]
n4[allowed_hosts_display = &#39;, &#39;.join...]
n5[lines = [&#39;Scope Configuratio...]
n6{if self.scope.exclusions}
n7[lines.append(&#39; Exclusions:&#39;&...]
n8{for exclusion in self.scope.exclus...}
n9[lines.append(f&#39; - {exclusion}...]
n10[]
n11{if len(self.scope.exclusions) &gt; 5}
n12[lines.append(f&#39; ... and {len(...]
n13[]
n14[]
n15[stats = self.get_stats()]
n16{if stats[&#39;total_checked&#39;]...}
n17[lines.append(&#39;\n Statistics:&#39...]
n18[lines.append(f&quot; Total Checked: {stat...]
n19[lines.append(f&quot; In Scope: {stats[...]
n20[lines.append(f&quot; Out of Scope: {stats...]
n21{if stats[&#39;total_checked&#39;]...}
n22[in_scope_percent = stats[&#39;in_scope&&#...]
n23[lines.append(f&#39; In Scope %: {in_s...]
n24[]
n25[]
n26[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n14
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n13
n12 --> n13
n13 --> n14
n14 --> n15
n15 --> n16
n16 -->|Yes| n17
n16 -->|No| n25
n17 --> n18
n18 --> n19
n19 --> n20
n20 --> n21
n21 -->|Yes| n22
n21 -->|No| n24
n22 --> n23
n23 --> n24
n24 --> n25
n25 --> n26
n26 --> n2
1356. scope manager Function get stats
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取統計信息\n\n Returns:\n ...]
n4[return self._stats.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取統計信息\n\n Returns:\n ...]
n4[return self._stats.copy()]
n1 --> n3
n3 --> n4
n4 --> n2
1357. scope manager Function is host allowed
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查主機名是否被允許\n\n Args:\n ...]
n4[return self._is_host_allowed(hostname...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查主機名是否被允許\n\n Args:\n ...]
n4[return self._is_host_allowed(hostname...]
n1 --> n3
n3 --> n4
n4 --> n2
1358. scope manager Function is in scope
flowchart TB
n1([開始])
n2([結束])
n3['\n 檢查 URL 是否在掃描範圍內\n\n Args:\n...]
n4[self._stats['total_checked'...]
n5[try]
n6[parsed = urlparse(url)]
n7{if not self._is_host_allowed(p...}
n8[logger.debug(f'Host not allowed: {pa...]
n9[self._stats['out_of_scope' ...]
n10[return False]
n11[]
n12{if self._matches_exclusion(url)}
n13[logger.debug(f'Matches exclusion pattern:...]
n14[self._stats['out_of_scope' ...]
n15[return False]
n16[]
n17[self._stats['in_scope'] += 1]
n18[return True]
n19[]
n20[except Exception]
n21[logger.warning(f'Failed to parse URL ...]
n22[self._stats['out_of_scope' ...]
n23[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n20
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n19
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 檢查 URL 是否在掃描範圍內\n\n Args:\n...]
n4[self._stats[&#39;total_checked&#39;&#...]
n5[try]
n6[parsed = urlparse(url)]
n7{if not self._is_host_allowed(p...}
n8[logger.debug(f&#39;Host not allowed: {pa...]
n9[self._stats[&#39;out_of_scope&#39;	...]
n10[return False]
n11[]
n12{if self._matches_exclusion(url)}
n13[logger.debug(f&#39;Matches exclusion pattern:...]
n14[self._stats[&#39;out_of_scope&#39;	...]
n15[return False]
n16[]
n17[self._stats[&#39;in_scope&#39;] += 1]
n18[return True]
n19[]
n20[except Exception]
n21[logger.warning(f&#39;Failed to parse URL ...]
n22[self._stats[&#39;out_of_scope&#39;	...]
n23[return False]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n5 --> n20
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 --> n9
n9 --> n10
n10 --> n11
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 --> n14
n14 --> n15
n15 --> n16
n16 --> n17
n17 --> n18
n18 --> n19
n19 --> n2
n20 --> n21
n21 --> n22
n22 --> n23
n23 --> n19
1359. scope manager Function is subdomain included
flowchart TB
n1([開始])
n2([結束])
n3['是否包含子域名']
n4[return self.scope.include_subdomains]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;是否包含子域名&#39;]
n4[return self.scope.include_subdomains]
n1 --> n3
n3 --> n4
n4 --> n2
1360. scope manager Function merge with
flowchart TB
n1([開始])
n2([結束])
n3['\n 合併另一個範圍管理器的配置\n\n Args:\n ...]
n4{for host in other.get_allowed...}
n5[self.add_allowed_host(host)]
n6[]
n7{for exclusion in other.get_exclusi...}
n8{if exclusion not in self.scope...}
n9[self.add_exclusion(exclusion)]
n10[]
n11[]
n12{if other.is_subdomain_included...}
n13[self.set_include_subdomains(True)]
n14[]
n15[logger.info('Merged scope configurations&...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 合併另一個範圍管理器的配置\n\n Args:\n ...]
n4{for host in other.get_allowed...}
n5[self.add_allowed_host(host)]
n6[]
n7{for exclusion in other.get_exclusi...}
n8{if exclusion not in self.scope...}
n9[self.add_exclusion(exclusion)]
n10[]
n11[]
n12{if other.is_subdomain_included...}
n13[self.set_include_subdomains(True)]
n14[]
n15[logger.info(&#39;Merged scope configurations&...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n4
n6 --> n7
n7 -->|Yes| n8
n7 -->|No| n11
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n10
n10 --> n7
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n14
n13 --> n14
n14 --> n15
n15 --> n2
1361. scope manager Function remove allowed host
flowchart TB
n1([開始])
n2([結束])
n3['\n 移除允許的主機\n\n Args:\n ...]
n4{if hostname in self._allowed_h...}
n5[self._allowed_hosts_set.remove(hostname)]
n6{if hostname in self.scope.allo...}
n7[self.scope.allowed_hosts.remove(hostname)]
n8[]
n9[logger.info(f'Removed allowed host: {...]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 移除允許的主機\n\n Args:\n ...]
n4{if hostname in self._allowed_h...}
n5[self._allowed_hosts_set.remove(hostname)]
n6{if hostname in self.scope.allo...}
n7[self.scope.allowed_hosts.remove(hostname)]
n8[]
n9[logger.info(f&#39;Removed allowed host: {...]
n10[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n10
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n8
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n2
1362. scope manager Function remove exclusion
flowchart TB
n1([開始])
n2([結束])
n3['\n 移除排除模式\n\n Args:\n ...]
n4{if pattern in self.scope.exclu...}
n5[self.scope.exclusions.remove(pattern)]
n6[self._exclusion_patterns = self._compile_exclus...]
n7[logger.info(f'Removed exclusion pattern: ...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 移除排除模式\n\n Args:\n ...]
n4{if pattern in self.scope.exclu...}
n5[self.scope.exclusions.remove(pattern)]
n6[self._exclusion_patterns = self._compile_exclus...]
n7[logger.info(f&#39;Removed exclusion pattern: ...]
n8[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n8
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1363. scope manager Function reset stats
flowchart TB
n1([開始])
n2([結束])
n3['重置統計信息']
n4[self._stats = {'total_checked...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;重置統計信息&#39;]
n4[self._stats = {&#39;total_checked&#3...]
n1 --> n3
n3 --> n4
n4 --> n2
1364. scope manager Function set include subdomains
flowchart TB
n1([開始])
n2([結束])
n3['\n 設置是否包含子域名\n\n Args:\n ...]
n4[self.scope.include_subdomains = include]
n5[logger.info(f'Set include_subdomains to: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 設置是否包含子域名\n\n Args:\n ...]
n4[self.scope.include_subdomains = include]
n5[logger.info(f&#39;Set include_subdomains to: ...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1365. scope manager Function validate scope
flowchart TB
n1([開始])
n2([結束])
n3['\n 驗證範圍配置的有效性\n\n Returns:\n ...]
n4[errors = []]
n5{for pattern in self.scope.exclus...}
n6[try]
n7[self._compile_pattern(pattern)]
n8[]
n9[except re.error]
n10[errors.append(f"Invalid exclusion pattern &a...]
n11[]
n12{for host in self._allowed_hos...}
n13{if not self._is_valid_hostname...}
n14[errors.append(f"Invalid hostname: &#...]
n15[]
n16[]
n17[is_valid = len(errors) == 0]
n18[return (is_valid, errors)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n6 --> n9
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n8
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n12
n16 --> n17
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 驗證範圍配置的有效性\n\n Returns:\n ...]
n4[errors = []]
n5{for pattern in self.scope.exclus...}
n6[try]
n7[self._compile_pattern(pattern)]
n8[]
n9[except re.error]
n10[errors.append(f&quot;Invalid exclusion pattern &a...]
n11[]
n12{for host in self._allowed_hos...}
n13{if not self._is_valid_hostname...}
n14[errors.append(f&quot;Invalid hostname: &#...]
n15[]
n16[]
n17[is_valid = len(errors) == 0]
n18[return (is_valid, errors)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 -->|Yes| n6
n5 -->|No| n11
n6 --> n7
n6 --> n9
n7 --> n8
n8 --> n5
n9 --> n10
n10 --> n8
n11 --> n12
n12 -->|Yes| n13
n12 -->|No| n16
n13 -->|Yes| n14
n13 -->|No| n15
n14 --> n15
n15 --> n12
n16 --> n17
n17 --> n18
n18 --> n2
1366. strategy controller Function init
flowchart TB
n1([開始])
n2([結束])
n3['\n 初始化策略控制器\n\n Args:\n ...]
n4[self.strategy = strategy.lower()]
n5[self._parameters = self._load_strategy_...]
n6[self._customizations: dict[str, Any] = {}]
n7[logger.info(f'StrategyController initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 初始化策略控制器\n\n Args:\n ...]
n4[self.strategy = strategy.lower()]
n5[self._parameters = self._load_strategy_...]
n6[self._customizations: dict[str, Any] = {}]
n7[logger.info(f&#39;StrategyController initiali...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1367. strategy controller Function load strategy parameters
flowchart TB
n1([開始])
n2([結束])
n3['\n 加載策略參數\n\n Returns:\n ...]
n4{if self.strategy in self._STRA...}
n5[return self._STRATEGY_PRESETS[self.st...]
n6[]
n7[logger.warning(f"Unknown strategy &#...]
n8[return self._STRATEGY_PRESETS[ScanStr...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 加載策略參數\n\n Returns:\n ...]
n4{if self.strategy in self._STRA...}
n5[return self._STRATEGY_PRESETS[self.st...]
n6[]
n7[logger.warning(f&quot;Unknown strategy &#...]
n8[return self._STRATEGY_PRESETS[ScanStr...]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n6
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1368. strategy controller Function apply to config
flowchart TB
n1([開始])
n2([結束])
n3['\n 將策略應用到配置控制中心\n\n Args:\n ...]
n4[params = self._parameters]
n5[config_center.update_crawling_config(max_depth=par...]
n6[config_center.update_dynamic_config(enabled=params...]
n7[config_center.update_performance_config(max_concur...]
n8[logger.info(f"Applied strategy '...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 將策略應用到配置控制中心\n\n Args:\n ...]
n4[params = self._parameters]
n5[config_center.update_crawling_config(max_depth=par...]
n6[config_center.update_dynamic_config(enabled=params...]
n7[config_center.update_performance_config(max_concur...]
n8[logger.info(f&quot;Applied strategy &#39;...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1369. strategy controller Function clone
flowchart TB
n1([開始])
n2([結束])
n3['\n 克隆當前策略控制器\n\n Returns:\n ...]
n4[new_controller = StrategyController(s...]
n5[new_controller._parameters = StrategyParameters(*...]
n6[new_controller._customizations = self._customizations...]
n7[return new_controller]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 克隆當前策略控制器\n\n Returns:\n ...]
n4[new_controller = StrategyController(s...]
n5[new_controller._parameters = StrategyParameters(*...]
n6[new_controller._customizations = self._customizations...]
n7[return new_controller]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n2
1370. strategy controller Function compare with
flowchart TB
n1([開始])
n2([結束])
n3['\n 比較與另一個策略的差異\n\n Args:\n ...]
n4{if other_strategy not in self....}
n5[logger.warning(f'Unknown strategy for com...]
n6[return {}]
n7[]
n8[other_params = self._STRATEGY_PRESE...]
n9[current_params = self._parameters]
n10[differences = {}]
n11{for field in current_params.__...}
n12[current_value = getattr(current_para...]
n13[other_value = getattr(other_params...]
n14{if current_value != other_value}
n15[differences[field] = (current_value, othe...]
n16[]
n17[]
n18[return differences]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n17
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n11
n17 --> n18
n18 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 比較與另一個策略的差異\n\n Args:\n ...]
n4{if other_strategy not in self....}
n5[logger.warning(f&#39;Unknown strategy for com...]
n6[return {}]
n7[]
n8[other_params = self._STRATEGY_PRESE...]
n9[current_params = self._parameters]
n10[differences = {}]
n11{for field in current_params.__...}
n12[current_value = getattr(current_para...]
n13[other_value = getattr(other_params...]
n14{if current_value != other_value}
n15[differences[field] = (current_value, othe...]
n16[]
n17[]
n18[return differences]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n7
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n9
n9 --> n10
n10 --> n11
n11 -->|Yes| n12
n11 -->|No| n17
n12 --> n13
n13 --> n14
n14 -->|Yes| n15
n14 -->|No| n16
n15 --> n16
n16 --> n11
n17 --> n18
n18 --> n2
1371. strategy controller Function customize
flowchart TB
n1([開始])
n2([結束])
n3['\n 自定義策略參數\n\n Args:\n ...]
n4{for (key, value) in kwargs.items()}
n5{if hasattr(self._parameters, key)}
n6[setattr(self._parameters, key, value)]
n7[self._customizations[key] = value]
n8[logger.debug(f'Customized parameter: ...]
n9[logger.warning(f'Unknown parameter: {...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n11
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n4
n11 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 自定義策略參數\n\n Args:\n ...]
n4{for (key, value) in kwargs.items()}
n5{if hasattr(self._parameters, key)}
n6[setattr(self._parameters, key, value)]
n7[self._customizations[key] = value]
n8[logger.debug(f&#39;Customized parameter: ...]
n9[logger.warning(f&#39;Unknown parameter: {...]
n10[]
n11[]
n1 --> n3
n3 --> n4
n4 -->|Yes| n5
n4 -->|No| n11
n5 -->|Yes| n6
n5 -->|No| n9
n6 --> n7
n7 --> n8
n8 --> n10
n9 --> n10
n10 --> n4
n11 --> n2
1372. strategy controller Function get available strategies
flowchart TB
n1([開始])
n2([結束])
n3['獲取所有可用的策略名稱']
n4[return list(cls._STRATEGY_PRESETS.key...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取所有可用的策略名稱&#39;]
n4[return list(cls._STRATEGY_PRESETS.key...]
n1 --> n3
n3 --> n4
n4 --> n2
1373. strategy controller Function get concurrent requests
flowchart TB
n1([開始])
n2([結束])
n3['獲取並發請求數']
n4[return self._parameters.concurrent_re...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取並發請求數&#39;]
n4[return self._parameters.concurrent_re...]
n1 --> n3
n3 --> n4
n4 --> n2
1374. strategy controller Function get max depth
flowchart TB
n1([開始])
n2([結束])
n3['獲取最大爬蟲深度']
n4[return self._parameters.max_depth]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取最大爬蟲深度&#39;]
n4[return self._parameters.max_depth]
n1 --> n3
n3 --> n4
n4 --> n2
1375. strategy controller Function get max pages
flowchart TB
n1([開始])
n2([結束])
n3['獲取最大頁面數']
n4[return self._parameters.max_pages]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取最大頁面數&#39;]
n4[return self._parameters.max_pages]
n1 --> n3
n3 --> n4
n4 --> n2
1376. strategy controller Function get parameters
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取當前策略參數\n\n Returns:\n ...]
n4[return self._parameters]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取當前策略參數\n\n Returns:\n ...]
n4[return self._parameters]
n1 --> n3
n3 --> n4
n4 --> n2
1377. strategy controller Function get recommended strategy for target
flowchart TB
n1([開始])
n2([結束])
n3['\n 根據目標特徵推薦策略\n\n Args:\n ...]
n4[recommendations = {('small&#...]
n5[key = (target_size.lower()...]
n6[recommended = recommendations.get(...]
n7[logger.info(f'Recommended strategy for ...]
n8[return recommended]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 根據目標特徵推薦策略\n\n Args:\n ...]
n4[recommendations = {(&#39;small&#...]
n5[key = (target_size.lower()...]
n6[recommended = recommendations.get(...]
n7[logger.info(f&#39;Recommended strategy for &#...]
n8[return recommended]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n7
n7 --> n8
n8 --> n2
1378. strategy controller Function get requests per second
flowchart TB
n1([開始])
n2([結束])
n3['獲取每秒請求數']
n4[return self._parameters.requests_per_...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取每秒請求數&#39;]
n4[return self._parameters.requests_per_...]
n1 --> n3
n3 --> n4
n4 --> n2
1379. strategy controller Function get strategy description
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取策略描述\n\n Args:\n ...]
n4[descriptions = {ScanStrategy.CONSER...]
n5[return descriptions.get(strategy, '未知...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取策略描述\n\n Args:\n ...]
n4[descriptions = {ScanStrategy.CONSER...]
n5[return descriptions.get(strategy, &#39;未知...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n2
1380. strategy controller Function get strategy name
flowchart TB
n1([開始])
n2([結束])
n3['獲取策略名稱']
n4[return self.strategy]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;獲取策略名稱&#39;]
n4[return self.strategy]
n1 --> n3
n3 --> n4
n4 --> n2
1381. strategy controller Function get strategy summary
flowchart TB
n1([開始])
n2([結束])
n3['\n 獲取策略摘要\n\n Returns:\n ...]
n4[params = self._parameters]
n5[lines = [f'Strategy: {self.s...]
n6{if self._customizations}
n7[lines.append('\n Customizations:&...]
n8{for (key, value) in self._customizati...}
n9[lines.append(f' {key}: {...]
n10[]
n11[]
n12[return '\n'.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;\n 獲取策略摘要\n\n Returns:\n ...]
n4[params = self._parameters]
n5[lines = [f&#39;Strategy: {self.s...]
n6{if self._customizations}
n7[lines.append(&#39;\n Customizations:&...]
n8{for (key, value) in self._customizati...}
n9[lines.append(f&#39; {key}: {...]
n10[]
n11[]
n12[return &#39;\n&#39;.join(lines)]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 -->|Yes| n7
n6 -->|No| n11
n7 --> n8
n8 -->|Yes| n9
n8 -->|No| n10
n9 --> n8
n10 --> n11
n11 --> n12
n12 --> n2
1382. strategy controller Function is aggressive
flowchart TB
n1([開始])
n2([結束])
n3['是否為激進策略']
n4[return self.strategy in [ScanStrategy...]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;是否為激進策略&#39;]
n4[return self.strategy in [ScanStrategy...]
n1 --> n3
n3 --> n4
n4 --> n2
1383. strategy controller Function is stealth
flowchart TB
n1([開始])
n2([結束])
n3['是否為隱秘策略']
n4[return self.strategy == ScanStrategy....]
n1 --> n3
n3 --> n4
n4 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;是否為隱秘策略&#39;]
n4[return self.strategy == ScanStrategy....]
n1 --> n3
n3 --> n4
n4 --> n2
1384. strategy controller Function reset customizations
flowchart TB
n1([開始])
n2([結束])
n3['重置所有自定義參數']
n4[self._parameters = self._load_strategy_...]
n5[self._customizations.clear()]
n6[logger.info(f"Reset customizations for strat...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2
flowchart TB
n1([開始])
n2([結束])
n3[&#39;重置所有自定義參數&#39;]
n4[self._parameters = self._load_strategy_...]
n5[self._customizations.clear()]
n6[logger.info(f&quot;Reset customizations for strat...]
n1 --> n3
n3 --> n4
n4 --> n5
n5 --> n6
n6 --> n2